Flask говорит, что работает, но код не отображается в браузере - PullRequest
0 голосов
/ 13 апреля 2019

Я пытаюсь запустить код Flask на компьютере с Windows 10. В командной строке написано, что приложение Flask обслуживается.

(HelloWorld) C:\Users\binoy\dev\HelloWorld>python HelloWorld.py
 * Serving Flask app "HelloWorld" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 211-440-231
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [13/Apr/2019 11:27:18] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [13/Apr/2019 11:27:18] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [13/Apr/2019 11:28:09] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [13/Apr/2019 11:28:17] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [13/Apr/2019 11:30:17] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [13/Apr/2019 11:34:05] "GET /favicon.ico HTTP/1.1" 404 -

Но когда я открываю браузер, я получаю сообщение 404 Not Found

Любая идея, почему я не могу увидеть приложение

1 Ответ

0 голосов
/ 13 апреля 2019

Спасибо, исправили. Я должен был изменить код.

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"
if __name__ == '__main__':
    app.run(host='0.0.0.0', threaded=True, debug=True)

Я вставил

`if _name_=='_main_':` 

до

 `@app.route("/") before `@app.route("/")`

Теперь он работает !!

...