推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
biexiawo
V2EX  ›  Python

Flask 应用程序如何部署到服务器?

  •  1
     
  •   biexiawo · Apr 1, 2016 via Android · 20722 views
    This topic created in 3875 days ago, the information mentioned may be changed or developed.
    项目已经写好,但不了解如何部署到服务器,求哪位朋友帮忙指导下,如果有这方面的教程或者博客就太好了
    29 replies  •  2018-07-26 15:05:15 +08:00
    tvallday
    tvallday
    Apr 1, 2016
    1
    根据我的经验,你需要一个 web server ,还要有反向代理 Nginx ,你也可以不用 Nginx ,但是现在这么流行学学也没坏处。 web server 我用的是 Unicorn.
    在 Google 上搜 Gunicorn flask server 。你就能找到答案。
    tvallday
    tvallday
    Apr 1, 2016
    2
    写错,应该是 Gunicorn 不是 Unicorn , Unicorn 是 Ruby 的 server 。还有其他的 server 你也可以看一下。当然你最好把 Gunicorn 启动加到 system service 里面去,然后你就可以 sudo systemctl gunicorn start 启动了。当然添加 system service 也有很多种办法, GoogleForWhatYouWant.
    csdreamdong
    csdreamdong
    Apr 1, 2016
    3
    apache + mod_wsgi
    biexiawo
    biexiawo
    OP
    Apr 1, 2016
    4
    @tvallday Thank you very much !!
    biexiawo
    biexiawo
    OP
    Apr 1, 2016
    5
    @csdreamdong 官方文档就是推荐的这种方法,但其介绍的太简略
    Kilerd
    Kilerd
    Apr 1, 2016
    6
    nginx uwign/gunicorn gevent superivor 一套搞定。
    biexiawo
    biexiawo
    OP
    Apr 1, 2016
    7
    @Kilerd 朋友能给推荐个教程吗?感激不尽
    aiver
    aiver
    Apr 1, 2016
    8
    一般是 Nginx + Gunicorn + Supervisor + Flask 部署,这里有一个在阿里云上部署的例子,你可以参考: http://www.simpleapples.com/2015/06/configure-nginx-supervisor-gunicorn-flask/,我之前也是在阿里云上部署的
    clino
    clino
    Apr 1, 2016
    9
    uwsgi 也很不错,跟 nginx 配合起来用
    lhbc
    lhbc
    Apr 1, 2016 via Android
    10
    uwsgi, 搜索一下就有文档,非常简单。
    uwsgi 是多进程的,简单成熟。
    yjd
    yjd
    Apr 1, 2016
    11
    重点是安全,不然就等着被 xx 了。
    crazyxin1988
    crazyxin1988
    Apr 1, 2016
    12
    virtualenv+supervisor+nginx+gunicorn
    strahe
    strahe
    Apr 1, 2016
    13
    搜一下 uwsgi + nginx 教程很多.
    wellsc
    wellsc
    Apr 1, 2016
    14
    官方文档和《 flask web 开发》不是教了你 N 种方法吗?伸手就行了
    biexiawo
    biexiawo
    OP
    Apr 1, 2016
    15
    @crazyxin1988 部署好了,用你的这个方法, 3Q !
    biexiawo
    biexiawo
    OP
    Apr 1, 2016
    16
    @Kilerd 恩,谢谢你的指导!
    biexiawo
    biexiawo
    OP
    Apr 1, 2016
    17
    @clino 嗯嗯,我还很菜但我会努力学的,谢谢!
    biexiawo
    biexiawo
    OP
    Apr 1, 2016
    18
    @csdreamdong 谢谢!
    biexiawo
    biexiawo
    OP
    Apr 1, 2016
    19
    @wellsc 嗯,我还要努力,谢谢
    Abirdcfly
    Abirdcfly
    Apr 2, 2016
    20
    给一个新浪云 SAE 部署的例子: http://abirdcfly.github.io/2016/03/07/flask-to-sae/
    KgM4gLtF0shViDH3
    KgM4gLtF0shViDH3
    Apr 2, 2016 via iPhone
    21
    youtube 搜 flask tutorial 就有了,一步一步教的。那小伙的教程都不错。
    biexiawo
    biexiawo
    OP
    Apr 2, 2016 via Android
    22
    @bestkayle 👍 谢了
    zwzmzd
    zwzmzd
    Apr 2, 2016 via Android❤️1
    23
    一般来讲 uwsgi 就够了。
    以下是我生产环境的配置,供参考

    uwsgi --http ":8080" --wsgi-file index.uwsgi --master --processes=5 --uid nobody --listen 5000 --static-map /static=static/
    clockwerk
    clockwerk
    Apr 2, 2016 via iPhone
    24
    用 python3 开发的,正在 ngnix gunicorn ,但是卡在 python3 不支持 supervisor 上了
    zvDC
    zvDC
    Apr 2, 2016
    25
    嗯,还在看 flask web
    zonghua
    zonghua
    Apr 4, 2016 via iPhone
    26
    @zwzmzd 竟然生产环境也用 http ,你不用守护进程?这都是前台进程啊
    struggling
    struggling
    Jan 6, 2017
    27
    请问你们有用 Windows 部署成功的吗?感觉 Windows 好多坑。。
    geek123
    geek123
    Mar 12, 2018
    28
    推荐一个 flask 的入门教程给大家,讲的挺清楚:

    http://xc.hubwiz.com/course/562427361bc20c980538e26f?affid=20180312v2ex
    gevin
    gevin
    Jul 26, 2018
    29
    我最近写了一篇相关的博客,不知对你有没有帮助

    https://blog.igevin.info/posts/how-to-deploy-flask-apps/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2267 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 74ms · UTC 13:51 · PVG 21:51 · LAX 05:51 · JFK 08:51
    ♥ Do have faith in what you're doing.