Forums

Receive and process https requests

Hello! Is there a way to process "Post" and "Get" https requests using pythonanywhere? I'd like to send those requests from my app. I can't find a tutorial or an article in "help" section. I'd appreciate any help on how to set it up.

At the moment I'm struggling with how connect my python code with the https request.

Could you clarify? I'm not sure whether you want to build a website that accepts POST and GET requests, or if you want to write code that makes POST and GET requests to other sites out there on the Internet. Both of those are possible (with the caveat that free accounts can only make POST and GET requests to sites on our whitelist), but of course it's important for us to know which one you're trying to do before making suggestions :-)

Of course.

1)My application(local .exe file on PC) would send a POST request to my pythonanywhere website. 2)On pythonanywhere website my Python code would process the data(as a text) and store it in a file on the server. 3)Then, when needed, my application(exe file) would send a "Get" request, then my Python code would send information back.

My question is how to make Python code on the server accept and process https requests(store info in file when there is "Post" request and process file and send info back when there's "Get" request).

Use a web app for that. That is pretty much exactly what web apps do.

I'd like to use WebApp but I can't find an instruction on how to process http requests.

I switched to "bottleApp" framework and it easily allows receicing http requests.

Code example:

from bottle import default_app, route,get, post, request

@get('/login') # or @route('/login') def login():
    username = request.forms.get('username')
    return username

Glad you figured that out!