对于 Python Web 开发,什么被认为是 CGI 的当前行业标准替代品?
What is considered the current industry standard alternative to CGI for Python web development?
在我上学期的 类 中,我不得不使用 CGI 脚本创建一个网站。虽然它很好地介绍了 Web 开发,但我可以看出它有其局限性。所以我的问题是,在当今的行业中,将 Python 脚本解析为 html 的最常见方法是什么?
我在 Stack Overflow 上发现了一些建议 PHP 使用 FastCGI 的帖子,但我想知道相同的答案是否适用于 Python。
WSGI 是一种描述网络服务器和网络应用程序之间(同步)通信的协议。 https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
I assume that I would use .py rather than .cgi? If that's the case, how would a web server know to run it?
这是旧思维方式:)
如今,您 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 可以在 Python 进程中使用不同的网络服务器 - gunicorn 是一种流行的服务器。
当然很多人仍然把 Nginx 或 Apache 作为 "reverse proxy" 放在他们的 Python 进程前面。本质上,这是为了处理 SSL/TLS,但有时也会进行负载平衡,如果您的 Python 进程已关闭,则自定义错误页面等。
在我上学期的 类 中,我不得不使用 CGI 脚本创建一个网站。虽然它很好地介绍了 Web 开发,但我可以看出它有其局限性。所以我的问题是,在当今的行业中,将 Python 脚本解析为 html 的最常见方法是什么?
我在 Stack Overflow 上发现了一些建议 PHP 使用 FastCGI 的帖子,但我想知道相同的答案是否适用于 Python。
WSGI 是一种描述网络服务器和网络应用程序之间(同步)通信的协议。 https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
I assume that I would use .py rather than .cgi? If that's the case, how would a web server know to run it?
这是旧思维方式:)
如今,您 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 可以在 Python 进程中使用不同的网络服务器 - gunicorn 是一种流行的服务器。
当然很多人仍然把 Nginx 或 Apache 作为 "reverse proxy" 放在他们的 Python 进程前面。本质上,这是为了处理 SSL/TLS,但有时也会进行负载平衡,如果您的 Python 进程已关闭,则自定义错误页面等。