Docker和WSGI使用Python金字塔应用程序?

2024-09-27 22:47:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在看两篇关于如何对接金字塔应用程序的文章。我对Python不是很熟悉,但我相当肯定,对于一个金字塔应用程序,您需要使用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解决方案是否可行?你知道吗


Tags: dockerhttpscom应用程序wsgionwith文章
1条回答
网友
1楼 · 发布于 2024-09-27 22:47:15

根据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解释了为什么wsgi服务器构建在if __name__=="__main__"块中

相关问题 更多 >

    热门问题