How are Python web applications deployed?

I am an ex-PHP developer, and I am struggling to understand that I can write a nginx script configuration, create directories, run nginx + PHP-FPM, load my code and let it run. I want to start playing with Python to feel this and start building web applications, but I lost a little how to make it all work.

Although some people’s advice will always use a framework like Django, I want to see how it all works from the bottom up.

I came across a Python web server mapping, and it seems that gevent is what I'm looking for. But how does it all fit together? Do I still need nginx (excluding static content) as a reverse proxy, or am I doing something else? I am confronted with the “novelty of blindness,” and I am struggling to understand how it all fits together.

+3
source share
3 answers

I myself am a beginner Python developer, so I had the same questions. Perhaps a more advanced user can fill out the details. Here is what I have done so far:

- script (.py) cgi-bin. hosthost.com/cgi-bin/your_script.py. , .

, "" .py script, . , , WSGI. , Apache, WSGI:

LoadModule wsgi_module libexec/apache2/mod_wsgi.so

<VirtualHost *:80>

WSGIScriptAlias /myapp /Library/WebServer/wsgi-scripts/views.wsgi

<Directory /Library/WebServer/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

views.wsgi - Python script. , localhost/myapp/-, views.wsgi. , .

:

def application(environ, start_response):
    start_response('200 OK', [('content-type', 'text/html')])
    return ['Hello world!']

environ , , , URLS , , , URL . - :

 path      = environ.get('PATH_INFO','')
 if path.startswith('/helloworld'):
  # call your function that returns HTML code

(, Django), , , HTML- , script. Django , (if, for ..), HTML. , , , .

, , , , - ...

+2

Python PHP. Python, , Python - - . WSGI,

- Django ngnix.

0

, pyton-.

100% python tornado

Apache, Nginx Lighttpd ( , C), mod (mod_wsgi, fgci uWsgi), - wsgi. , apache + some_mod PHP-.

, Apache + mod_wsgi Nginx + uWsgi

0

All Articles