我想運行一個Python程序:它是正確的蟒蛇包「應用程序」?
from app import app
@app.route('/')
@app.route('/index')
def index():
return "Hello, World!
我發現它從https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world。它使用包「應用程序」。但是當我運行它時,它會給出錯誤:
from app import app
ImportError: cannot import name 'app'
我用pip安裝了包「app」。在包文件夾(/usr/local/lib/python3.5/dist-packages/app)中的Init.py文件中沒有類「app」。在文件init .py只有2個函數 - hello()和add(x,y)。該INIT的.py是以下幾點:
def hello():
return 'Hello world!'
def add(x,y):
return x+y
是不是同一個包「應用程序」是劇本,我發現要進口?我該怎麼做才能讓腳本運行?
這是一個瓶教程。你想用Flask創建一個網站嗎? –