2016-12-29 6 views
1

__init__ .pyファイルをFlaskで更新しようとすると、サーバに変更が反映されませんが、home.htmlを編集すると正常に動作します。Flask __init__.pyは変更を表示しません

アプリ/ __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() 

任意のヒント?

+0

'app.run(debug = True)'に変更してください。 – Maroun

+0

リロードするか、開発中の場合は 'debug = True'を有効にしてください – metmirr

+0

no luck ...' app.run() 'を' app.run(debug = True) 'に変更しましたが、まだ更新しません。 – Kevin

答えて

1

私たちはコメントでこの問題を解決しましたが、他の誰かが同様の問題を抱えている場合は、ここで解決策を追加します。開発環境は、アプリケーションサーバ上で動作する場合は、開発環境については

アプリ

app.run(debug=True)

debug=True引数を追加し、その後、自動再オプションを探してください。 uWSGIには、例えばpy-auto-reloadがあります。

リリースされた安定した環境では、アプリケーションサーバーを再起動する必要があります。

は、例えばuWSGI

にuWSGIが正常に再起動させるには、いくつかの方法があります。

# 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 

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

警告:あなたはたとえば、アプリケーションとウェブサーバ、uWSGIとnginxのを組み合わせた場合は、nginxのを再起動すると、アプリケーションのコードをリロードしません。アプリケーションサーバーに焦点を当てます。

関連する問題