生产中的Python SimpleHTTPServer [英] Python SimpleHTTPServer in production
问题描述
我想用Python提供静态文件. Python 3 http.server
是否适合在生产中使用?如果没有,为什么不呢?那我有什么选择呢?
I want to serve static files with Python. Is the Python 3 http.server
suitable for use in production? If not, why not? And what are my alternatives?
推荐答案
引用文档 https://docs.python.org/3/library/http.server.html#module-http.server
警告:不建议将http.server用于生产.它只是 实现基本的安全检查.
Warning: http.server is not recommended for production. It only implements basic security checks.
首先,您完全不需要python即可提供静态文件.只需使用真实的HTTP服务器(如Apache或NGinx)即可.如果要快速解决方案,只需寻找一个带有适合您需求的预配置映像的docker容器.这是 NGinx .码头工人绝对是必须具备的 您不会后悔学习的工具.
First of all you don't need python at all to serve static files. Just use a real HTTP Server like Apache or NGinx. If you want a quick solution just look for a docker container with a pre-configured image suitable for your needs. Here is the NGinx. Definitely docker is a must have tool that you will not regret to learn.
$ docker run --name mysite-nginx -v /mysite:/usr/share/nginx/html:ro -p 80:80 -d nginx
这篇关于生产中的Python SimpleHTTPServer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!