What is considered the current industry standard alternative to CGI for Python web development?

核能气质少年 提交于 2021-02-04 19:18:25

问题


For one of my classes last semester I had to create a website using a CGI script. While it was a good introduction to web development, but I can see it has it's limitations. So my question is, in the industry today, what is the most common approach for parsing a Python script into html?

I have found a few posts on Stack Overflow that suggest FastCGI for PHP, but I am wondering if the same answers apply to Python.


回答1:


I assume that I would use .py rather than .cgi? If that's the case, how would a web server know to run it?

This is a old way of thinking :)

Nowadays you start your Python process, and it begins to listen on a port. The Python process itself contains a webserver and is almost completely self-contained - see here for the different webservers you can use within your Python process - gunicorn is a popular one.

Of course a lot of people still put Nginx or Apache in front of their Python process as a "reverse proxy". Essentially this is to handle SSL/TLS but also sometimes to do load balancing, custom error pages if your Python process is down etc.




回答2:


WSGI is a protocol that describes (synchronous) communication between a web server and a web application. https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface



来源:https://stackoverflow.com/questions/34540936/what-is-considered-the-current-industry-standard-alternative-to-cgi-for-python-w

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!