源码1.py
from flask import Flask
app=Flask(__name__)
@app.route("/")
def index():
return "{a:1,b:2}"
app.run(host='139.....',port=4444)
139.....是阿里ECS的公网IP
cmd python 1.py的报错信息
Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>cd C:\Users\Administrator\Desktop\back
C:\Users\Administrator\Desktop\back>python 1.py
* Serving Flask app "1" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployme
nt.
Use a production WSGI server instead.
* Debug mode: off
Traceback (most recent call last):
File "1.py", line 8, in <module>
app.run(host='139.196.31.15',port=4444)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-p
ackages\flask\app.py", line 990, in run
run_simple(host, port, self, **options)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-p
ackages\werkzeug\serving.py", line 1052, in run_simple
inner()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-p
ackages\werkzeug\serving.py", line 996, in inner
srv = make_server(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-p
ackages\werkzeug\serving.py", line 847, in make_server
return ThreadedWSGIServer(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-p
ackages\werkzeug\serving.py", line 740, in __init__
HTTPServer.__init__(self, server_address, handler)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\socket
server.py", line 452, in __init__
self.server_bind()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\http\s
erver.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\socket
server.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [WinError 10049] 在其上下文中,该请求的地址无效。
改成app(host='localhost',port=4444)
之后ECS服务器上访问http://localhost:4444
可以正常获取
计划用pymysql和flask来交互传输前端数据,想问问是什么错误。。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。