Example URL = https://westgate-production-4cb87.firebaseapp.com/super-contests/weekly-card/embed
I've written the code needed to get this to work with the current deployed websocket URL and successfully scrape the data on this page -
wss://s-usc1c-nss-276.firebaseio.com/.ws?v=5&ns=westgate-production-4cb87
However, it seems that every so often the number in the subdomain will change (in this example - 276). I can obviously manually figure out what the new URL is using the Network tab in Dev Tools, but I was wondering if there was a Python code snippet or some approach where I can programatically detect what websockets are opening so that I can capture the wss:// URL and then pass it into the rest of my code that works correctly.
Thank you!
You're using an undocumented way to access the Firebase Realtime Database.
That first part of the URL is the server that your client is connecting to to access the data, and is actually determined by the first request(s) when the connection is established. But as said, this knowledge is not documented and can thus change at any time without notice.
I'd recommend using either the Python SDK, the REST API, or the REST Streaming API to access the database, as all of those are properly documented.
Related
I have a Python FastAPI Backend which gives me an endpoint in order to retrieve some oAuth data. The Endpoint works when i put it manually in my Browser. It first does a redirect retrieves an accessToken which it then adds to a second link and opens it. So the functionality works. Now i'm a bit stuck on how to get this data in my Frontend. I tried a GET request on the original endpoint but then get the response with the redirect link. What would be a clever way to handle this? I would like to store the data in the Frontend in order to manipulate it
Thanks for helping me!
After doing many OAuth2 interactions, I recommend you use a library; OAuth2 flow is fairly complicated with the interactions between Client, Backend, Identification, & Authorization servers. Using a library helps ensure you are doing all the key swaps properly and securely; Also it will save you lots of time :).
Here is a library I would use in your shoes; https://github.com/manfredsteyer/angular-oauth2-oidc
Actual situation:
The client downloads a small pythonscript that is executable.
The client executes it. The script gathers information from the computer and sends the data to the webserver viĆ POST-Method.
Wanted Situation:
After the webserver recived the data, it should forward the information to the website-session of the client. And the website should display the information.
This is a visual example of the principle:
There is also a example of this principle on Can You Run It.
How can I realize this?
A common way of implementing this is using a RESTful API. Basically the API does not care if the request is from a script or web browser, it just passes data structures to and from clients. The only tricky part to your example is when there are multiple users involved because a secret must be shared between the browser and script. I believe Can You Run It puts this unique secret into the program they ask you to download.
Look into Django Rest Framework for examples of how to implement this.
In my GAE app when the request page is appid.appspot.com/module?action=form using the code snippet below I am getting this ouput appid.appspot.com/_ah/upload/?action=form/fu6YsSdQIK6rzh9e3Q6t...fu6YsSdQIK6rzh9e3Q6t/
blobstore.create_upload_url('module/')
The URL I want to create should be like this
appid.appspot.com/module/_ah/upload/fu6YsSdQIK6rzh9e3Q6t...fu6YsSdQIK6rzh9e3Q6t?action=edit
Is there a standard way to achieve this
No, you have not read the documentation. You don't get to control the upload URL: the parameter you pass is where the browser gets redirected to after the upload. The upload destination is controlled by GAE itself and cannot be changed from your code.
I had the same problem with my deployment. I don't know why it started happening with that setup beyond the fact that I was using a custom domain on the app (and removing it had no effect). In the end, though, it didn't seem to affect anything. Once I had my permissions set up right (oops) uploads worked fine despite the wonky URL.
As a non webdev, I'd really like if you could point me out to the 'correct' way to do this.
I built an application that populates and updates a database periodically (sqlite to be precise). I store leaderboards in my database, and would like to display them in a webpage.
As my leaderboards can change all the time, I need the webpage to be dynamic, either on a time based trigger or whenever the database changes.
I was about to use javascript for that, by realized that my database is hosted on my server, so client side js might not work.
Any ideas on that?
As my app is built in Python, I'd prefer avoid using php solutions but use more 'trendy' technologies (js, ruby, python, ? ? ? whatever)
Thanks!
Ok, given the keywords I got now here is an almost exact duplicate :
Notify user on database change? JavaScript/AJAX
This is what Ajax is for. You write Javascript on the front end that uses Ajax to call your server-side code to return the database content, then updates your HTML when it receives a response.
You need to use javascript on the client side not on the server. Your javascript code will make async calls (using ajax) to check if the db changed and update the website accordingly.
You can either use javascript to poll the server side periodically. Or you can use javascript to create (perhaps using a library like SockJS or SocketIO) a websocket connection that can actually push data to the client side when it changes. I do this on a number of projects using Tornado's websocket support on the server side.
I tried using Google's GEOLOCATION api and html5 to get device location. Both methods get data using JavaScript.
I also know I am able to get street/city name information from Google's GEOCODING api using JSON.
I am also able to fetch map tiles from openstreetmaps/cloudemade from a specific latitude, longitude.
Big question now. Points 2 and 3 are done using Python. How do I supply lat/long info from point 1 to Python running on server?
If you are running Javascript code in your browser that needs to communicate with some Python code running somewhere else, then the easiest way to get them to communicate is by settings up an HTTPServer in Python. The javascript will then be able to make HTTP Requests to the Python server.
You'll probably be able to get by by just extending Python's built-in HTTP server class.
As far as the format via which you should send the data, I would recommend JSON, because Javascript in the browser and Python on the server side are able to "do JSON" fairly easily.