我想运行一个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创建一个网站吗? –