First, follow written a very simple application Flask, direct error
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "1234" if __name__=="__main__": app.run()
Report an error
Traceback (most recent call last): File "<input>", line 1, in <module> File "D:\python\install\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "D:\python\install\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "E:/Python/UseTest.py", line 8, in <module> app.run() File "C:\Users\youziku\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 990, in run run_simple(host, port, self, **options) File "C:\Users\youziku\AppData\Roaming\Python\Python36\site-packages\werkzeug\serving.py", line 1009, in run_simple inner() File "C:\Users\youziku\AppData\Roaming\Python\Python36\site-packages\werkzeug\serving.py", line 962, in inner fd=fd, File "C:\Users\youziku\AppData\Roaming\Python\Python36\site-packages\werkzeug\serving.py", line 805, in make_server host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd File "C:\Users\youziku\AppData\Roaming\Python\Python36\site-packages\werkzeug\serving.py", line 698, in __init__ HTTPServer.__init__(self, server_address, handler) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\socketserver.py", line 453, in __init__ self.server_bind() File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\http\server.py", line 138, in server_bind self.server_name = socket.getfqdn(host) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\socket.py", line 673, in getfqdn hostname, aliases, ipaddrs = gethostbyaddr(name) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 8: invalid start byte
I stepped on the mine for two days, and now record what, error-prone points
1) is a coding problem code, will re-save the page to utf-8.
2) computer name is Chinese, and the user name is Chinese
3) port is used to manually specify the port
When the current two useless, you may wish to specify what port
if __name__ == '__main__': app.run(host="0.0.0.0", debug=True, port=9999)