while I have quite some python experience, I’ve never used it for web and I have vast amount of web experience with PHP.
Now I want to create a simple python script (lets call it service.py) that runs on example.com. I installed mod_wsgi as suggested by the docs, my web server is Apache 2.2, the mod_wsgi is loaded successfully.
How do I configure my web server/mod_wsgi so that requests comming to example.com/service are processed by service.py?
Then how do I access the request params (like $_GET, $_POST, $_FILES) from the python script?
With mod_wsgi, you configure which URLs are served by setting
WSGIScriptAlias. Your script, though, needs to be an actual WSGI application, which exposes anapplicationvariable which is called by the server.I suspect it’d be easier to configure your script as simple CGI. You can then use the
cgimodule from the standard library to access your request params (note, though, that the examples you give are PHP-specific: they’re accessed differently in Python, depending on the specific framework).Another alternative would be to use a mini-framework like Flask, which would encapsulate all this and give you a simple interface to use in your service.py script.