烧瓶__init__.py不显示更改 [英] Flask __init__.py doesn't show changes

查看:255
本文介绍了烧瓶__init__.py不显示更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试更新Flask中的 __ init __ .py文件时,它不显示服务器中的更改,但是当编辑 home.html 它工作正常。

app / __ init __ .py

  import flask $ b $ from flask flask Flask,render_template $ b $ from werkzeug.contrib.fixers import ProxyFix 
app = Flask(__ name__)

$ app_route('/')
def home():
return render_template('home.html')
$ b $ app.wsgi_app = ProxyFix(app.wsgi_app)
app.debug = bool(os.environ.get('PRODUCTION'))

if __name__ =='__main__':
app.run()

任何提示?

解决方案

我们在注释中解决了这个问题,但是如果其他人有类似的问题,我会在这里添加解决方案。

code> debug = True 参数到您的应用程序



app.run(debug = True)



环境在应用程序服务器上工作,那么你应该寻找autoreload选项。在uWSGI中有 py-auto-reload 例如。

对于已发布的稳定的环境,您应该重新启动应用程序服务器。



例如在 uWSGI


有几种方法可以使uWSGI正常重启。

 #使用kill发送信号
kill -HUP`cat / tmp / project-master.pid`
#或者方便的选项--reload
uwsgi --reload /tmp/project-master.pid
#或者uwsgi是以touch-reload = / tmp / somefile开头的
touch / tmp / somefile


更多: http://uwsgi-docs.readthedocs.io/en/latest/Management.html#reloading-服务器



警告:如果您将应用程序和Web服务器(例如uWSGI和Nginx)组合起来,那么重新启动Nginx将不会重新加载您的应用程序代码。专注于应用程序服务器。


When I try to update the __init__.py file in Flask, it doesn't show the changes in the server, but when I edit home.html it works fine.

app/__init__.py

 import os
    from flask import Flask, render_template
    from werkzeug.contrib.fixers import ProxyFix
    app = Flask(__name__)

    @app.route('/')
    def home():
        return render_template('home.html')

    app.wsgi_app = ProxyFix(app.wsgi_app)
    app.debug = bool(os.environ.get('PRODUCTION'))

    if __name__ == '__main__':
        app.run()

Any tips?

解决方案

We solved the problem in comments but I will add solution here if someone else has a similar problem.

For development environment add debug=True argument to your app

app.run(debug=True)

If your development environment works on an application server, then you should look for autoreload option. In uWSGI there is py-auto-reload for example.

For released, stable environment you should restart your application server.

For example in uWSGI

There are several ways to make uWSGI gracefully restart.

# using kill to send the signal
kill -HUP `cat /tmp/project-master.pid`
# or the convenience option --reload
uwsgi --reload /tmp/project-master.pid
# or if uwsgi was started with touch-reload=/tmp/somefile
touch /tmp/somefile

More: http://uwsgi-docs.readthedocs.io/en/latest/Management.html#reloading-the-server

Warning: if you combine application and web server, uWSGI and Nginx for example, then restarting Nginx won't reload your application code. Focus on the application server.

这篇关于烧瓶__init__.py不显示更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆