Docker 和带有 Python Pyramid 应用程序的 WSGI?

Docker and WSGI with a Python Pyramid app?

我正在看两篇关于如何将 Pyramid 应用程序 Dockerize 的文章。我对 Python 不太熟悉,但我相当确定您需要使用 WSGI 的 Pyramid 应用程序。

本文使用WSGI: https://medium.com/@greut/minimal-python-deployment-on-docker-with-uwsgi-bc5aa89b3d35

这个只是 运行 直接 python 可执行文件: https://runnable.com/docker/python/dockerize-your-pyramid-application

在我看来你不太可能直接 运行 python 而不是合并 WSGI,任何人都可以解释为什么 runnable.com 文章的 docker 解决方案会工作?

根据 second link 中的脚本:

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

~snip~

if __name__ == '__main__':
    config = Configurator()
    config.add_route('hello', '/')
    config.add_view(hello_world, route_name='hello')
    app = config.make_wsgi_app() # The wsgi server is configured here
    server = make_server('0.0.0.0', 6543, app) # and here

This 包含对为什么在 if __name__=="__main__"

中构建 wsgi 服务器的解释