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

标签 python docker pyramid

我正在看两篇有关如何对金字塔应用程序进行Docker化的文章。我对Python不太熟悉,但是我可以肯定使用Pyramid应用程序需要使用WSGI。

本文使用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服务器

关于python - 带有Python Pyramid应用程序的Docker和WSGI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55871776/

相关文章:

Python 打开和关闭文件 - 不直观

docker - 无法推送到 docker hub(需要身份验证)

python - 使用 Python Requests 库上传大型 XML 文件

python - 仅删除引号中句子的特定部分

docker - 在运行时将环境变量传递给 Vue 应用程序

docker - 使用 docker 镜像在 Heroku 上部署 Go App + Vue.js

python - 将 POST 请求限制为 Pyramid 上的最大大小

python - 设置 Pyramid Web 框架 | FCGI 共享主机

python - 如何让 Pyramid invoke_subrequest 通过 view_config 上下文路由进行错误处理

python - Google App Engine - 让 session 与 Python 2.7 一起工作