m0_37040206
m0_37040206
2018-07-13 12:14

为什么用python写的flask示例程序无法运行,刚刚接触这个,请大佬指教一下

5
  • app
  • python
  • utf-8
  • 编码

#-*- encoding=UTF-8 -*-
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
return "Hello World!"

if name == '__main__':
app.run()

提示的错误如下:
"F:\pycharm projects\venv\Scripts\python.exe" "F:/pycharm projects/ftest.py"

  • Serving Flask app "ftest" (lazy loading)
  • Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead.
  • Debug mode: off Traceback (most recent call last): File "F:/pycharm projects/ftest.py", line 11, in app.run() File "F:\pycharm projects\venv\lib\site-packages\flask\app.py", line 943, in run run_simple(host, port, self, **options) File "F:\pycharm projects\venv\lib\site-packages\werkzeug\serving.py", line 814, in run_simple inner() File "F:\pycharm projects\venv\lib\site-packages\werkzeug\serving.py", line 774, in inner fd=fd) File "F:\pycharm projects\venv\lib\site-packages\werkzeug\serving.py", line 660, in make_server passthrough_errors, ssl_context, fd=fd) File "F:\pycharm projects\venv\lib\site-packages\werkzeug\serving.py", line 577, in init self.address_family), handler) File "C:\Users\asus\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 453, in init self.server_bind() File "C:\Users\asus\AppData\Local\Programs\Python\Python36-32\lib\http\server.py", line 138, in server_bind self.server_name = socket.getfqdn(host) File "C:\Users\asus\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 673, in getfqdn hostname, aliases, ipaddrs = gethostbyaddr(name) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbd in position 0: invalid start byte
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

6条回答