<>hello.py遇见的几个坑

阅读更多

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

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

@app.route('/user/')
def user(name):
    return '

Hello, %s!

' % 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

 

最后完美解决!

你可能感兴趣的:(Importing,is,deprecated,use,flask_script,instead)