[Python] python flask can't find '__main__' module in ''

Discussão em 'Python' iniciado por Stack, Fevereiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    Hi All I am just learning about flask. I have used pip to install it. Then when I run this basic code I get an error. Basically I see its working then abruptly exits with the following error. This maybe looks to be some environment issue but I'm not sure. The strange thing this was working the other day now it's not.

    from flask import Flask
    app = Flask(__name__)

    @app.route('/')
    def hello_world():
    return 'Hello, World!'


    if __name__ == '__main__':
    app.run(debug=True, port=8000, host='0.0.0.0')

    * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
    * Restarting with stat
    /Library/Frameworks/Python.framework/Versions/3.4/bin/python3: can't find '__main__' module in ''

    Continue reading...

Compartilhe esta Página