from flask import Flask
app=Flask(__name__)#导入和设置Flask
@app.route('/')#调用一种特殊类型的函数,称之为装饰器。
#在这里指明了想要页面从何处提供。斜杠表示想要它从URL的根目录下提供
def hello_world():
return 'Hello World!'
#这个函数告诉Flask,想把哪些数据发送给那个页面
if(__name__=='__main__'):
app.run()
#调用一个名为run()的Flask函数
上面是我的Python代码,下面是我的报错信息
Traceback (most recent call last):
File "F:\大学\python\Flaskhello.py", line 13, in <module>
app.run()
File "F:\大学\python\lib\site-packages\flask\app.py", line 938, in run
cli.show_server_banner(self.env, self.debug, self.name, False)
File "F:\大学\python\lib\site-packages\flask\cli.py", line 629, in show_server_banner
click.echo(message)
File "F:\大学\python\lib\site-packages\click\utils.py", line 218, in echo
file = _default_text_stdout()
File "F:\大学\python\lib\site-packages\click\_compat.py", line 675, in func
rv = wrapper_func()
File "F:\大学\python\lib\site-packages\click\_compat.py", line 436, in get_text_stdout
rv = _get_windows_console_stream(sys.stdout, encoding, errors)
File "F:\大学\python\lib\site-packages\click\_winconsole.py", line 295, in _get_windows_console_stream
func = _stream_factories.get(f.fileno())
io.UnsupportedOperation: fileno
这是我在DOS界面多次安装了Flask以后的语句
C:\Users\DELL>pip install flask
Requirement already satisfied: flask in f:\大学\python\lib\site-packages (1.0.2)
Requirement already satisfied: Werkzeug>=0.14 in f:\大学\python\lib\site-packages (from flask) (0.15.2)
Requirement already satisfied: click>=5.1 in f:\大学\python\lib\site-packages (from flask) (7.0)
Requirement already satisfied: itsdangerous>=0.24 in f:\大学\python\lib\site-packages (from flask) (1.1.0)
Requirement already satisfied: Jinja2>=2.10 in f:\大学\python\lib\site-packages (from flask) (2.10.1)
Requirement already satisfied: MarkupSafe>=0.23 in f:\大学\python\lib\site-packages (from Jinja2>=2.10->flask) (1.1.1)