Create upload URL using blobstore.create_upload_url() - python

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.

Related

Automatically Detect Websocket Path (Firebase)

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.

PyQt open urls from custom uri scheme in the same app instance

I don't know if this has been answered somewhere on here or not but I can't really find anything that has helped me.
Anyway, I am working with PyQt5 on windows and I created a custom URI scheme that opens my app and then the app parses the command arguments and then does the needed processing. Everything is working as expected but I am trying to figure out how to make everything open in the same app instance.
For example, if I have several custom links such as
foo://bar
foo://bar2
foo://bar3
How can I make them all open in the same instance without opening a new app each time they are executed?
In case anyone is interested, I found what seems to be a pretty good solution, at least for what I need. After a lot of looking around I came across this Answer which is using sockets. I altered it a bit to fit my needs and created a client.exe file that I associate with my custom URI scheme now instead of my main app. So instead of using my main app path in the URL Protocol registry key I now use this instead.
"C:\testapp\client.exe" "--data" "%1"
So now when I click a link such as :
foo://bar
The command is ran and opens client.exe and I simply parse the arguments with argparse and then send the data through the socket to my main app. I don't know if there is a better way to do this but it seems to work well for a simple solution.

Spotipy/Spotify - How to put a spotipy script on a server?

I am doing a Spotipy script that I want to automize and put it on a server.
By "automize" I mean that for the authentification I don't want to have to copy/paste the open URL (I'm using Authorization Code Flow), is it possible? Or maybe there is a way to catch that opened URL and paste it automatically to the program on the server?
Thank you.
If I understand you correctly:
You can use Flask: http://flask.pocoo.org/, which is a microframework for serving applications (your scripts).
This way, every time you go to URL on your browser (Flask default is localhost:5000), authorization code will run automatically, and you can then be redirected to your served pages, as long as you have templates (html) for them.
Here's an example of how you can implement one app:
https://github.com/datademofun/spotify-flask
And here's a Walkthrough of Authorization Code Flow using Flask and Python, with the Spotify API:
https://github.com/drshrey/spotify-flask-auth-example

Should I use GET or POST to send commands to server?

I am developing a simple application in python that provides a browser based interface using a local server. The structure is like this:
[Interface] <===> { [Server] <---> [Application] }
My application has a class function called, say, compute(). On my browser interface, I have a button Compute. When the user clicks it, I want to run compute(). My current approach is to send a GET request like /path/compute. The server identifies the request path and runs the function. Is this the correct way to go about it?
From this accepted answer:
GET is used for viewing something, without changing it, while POST is used for changing something
I am not using GET here to view something immediately, but to send a command that changes the state of the application. Should I use POST instead? Is there another method?
Yes indeed, you must use a POST request here. You may want to read about REST APIs for more about the correct use of http verbs. The HTTP rfc is also a must-read...

Auth_token error at Facebook

i have been on this for the last 2 days with no result.
i am running my facebook app on my localhost with port-forwarding method.
i know my server setup is working fine as i can see the logs on the django runserver and dyndns log as well.
django is properly responding to calls as well.
the problem is as soon as the app authorizes with my user account, it straight follows to the page that says this:
Errors while loading page from application
The URL http://amitverma.dyndns.org/facebook_sample/?auth_token=817f8fbe99eff10582b634589de17b84 is not valid.
Please try again later. We appreciate your patience as the developers of app_test and Facebook resolve this issue. Thanks!
I am making a test app learning from facebook + django tutorial from here and here.
I am still getting this error and I have no idea what i am doing wrong...
Please help me out.
This often happens with a failed authentication. I'm not sure what the Python client libraries might look like, but with the PHP ones you generally make an authorization call against the library, something like $facebook->require_login().
With the PHP library, if this call fails to verify the user's Facebook session, then it automatically outputs HTML that will redirect the browser and try to re-establish the session, hence the auth_token parameter.
I suspect you're running into something similar. Try to isolate any authentication calls you're making, and use a Firefox extension like LiveHTTPHeaders to see if you are undergoing any redirects during the requests.
When you get that error, presuming you have debug=True in the Django settings and that your application is in development mode in Facebook, you can do View Source and see the entire Django error page that would normally display, including traceback. Facebook comment it out in the HTML so it doesn't show on the front end, but you can copy and paste it into a separate HTML file and view that in your browser to see the nice friendly Django error page which will definitely give you a clue as to what's going wrong.

Categories

Resources