zhangshufei8001 阅读(28) 评论(0)

在看<<flask web开发>>文章中第16页,在做示例2-3时,

from flask import Flask
app = Flask(__name__)
from flask.ext.script import Manager
manager = Manager(app)

@app.route('/user/<name>')
def user(name):
    return '<h1>Hello, %s!</h1>' % name

if __name__=='__main__':
    manager.run()
在运行时报以下错误:

E:\Python36>python hello.py
hello.py:42: ExtDeprecationWarning: Importing flask.ext.script is deprecated, use flask_script instead.
  from flask.ext.script import Manager
usage: hello.py [-?] {shell,runserver} ...

positional arguments:
  {shell,runserver}
    shell            Runs a Python shell inside Flask application context.
    runserver        Runs the Flask development server i.e. app.run()

optional arguments:
  -?, --help         show this help message and exit

 

这里面告诉了我们两条有用的信息,第一条就是,我们应该导入from flask_script import Manager

第二条就是运行的时候,我们应该写成E:\Python36>python hello.py runserver

 

最后完美结决!