Flask - ImportError: No module named app

前端 未结 7 1538
故里飘歌
故里飘歌 2020-12-15 16:31

First I created __init__.py

from flask import Flask

app = Flask(__name__)

Then in a separate file, in the same directory,

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 16:34

    __init__.py is imported using a directory. if you want to import it as app you should put __init__.py file in directory named app

    a better option is just to rename __init__.py to app.py

提交回复
热议问题