简体   繁体   中英

Flask app.py providing no output or log when running

I am learning flask for first time i ran this program on my virtualenv and on my system but getting similar ouput which is nothing on the console.

Code:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

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

Output:

I believe you need to indent your last line, app.run() . This is because you only want it to run when the __name__ is equal to '__main__' . You should then be able to run the program by exporting it and running it with the flask run command. Here is a more detailed explanation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM