Python SimpleHTTPServer in production

天涯浪子 提交于 2019-12-01 14:45:22

问题


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?


回答1:


Quoting documentation https://docs.python.org/3/library/http.server.html#module-http.server

Warning: http.server is not recommended for production. It only implements basic security checks.

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


来源:https://stackoverflow.com/questions/33392293/python-simplehttpserver-in-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!