当前位置:网站首页>When using flash, the code ends automatically without an error, the connection cannot be maintained, and the URL cannot be accessed.
When using flash, the code ends automatically without an error, the connection cannot be maintained, and the URL cannot be accessed.
2022-04-23 07:53:00 【Apple Laboratory of Central South University】
author :cyl
Time :2021.11.3
One 、 Error description
Learning to use python Lightweight web The service , come to know flask library . But there was a problem executing an entry-level code :
from flask import Flask # Import flask library
app = Flask(__name__) # establish flask example
# Use app.route Modifier to define a url, When visiting this url You can automatically call the function under the modifier ( My personal current understanding , Not necessarily )
@app.route("/a")
def testflask():
print("hello world")
return 'Hello World!'
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)# Start port , perform app.run You can start the service . Default Flask Only listen to the local of the virtual machine 127.0.0.1 This address , Port is 5000. Using parameters instead 0.0.0.0 Can listen to all ports .
In principle , The correct result of running after execution is :

It's a case of keeping connected .
But mine is :


Although executed correctly, it automatically ends execution .
Two 、 The reason for the error
I didn't have this problem because python Wrong version or flask Wrong version . But because python Will automatically test The first function is executed as a test . In fact, the information returned from the above figure can also be seen .( It seems that naming can't be fooled ,python Many constraints are easy to use )

3、 ... and 、 Error resolution
Change function name

Perfect execution
Although the reason for the error is different from the title of my article . Just take a look at that .
If it helps you , Do me a favor
版权声明
本文为[Apple Laboratory of Central South University]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230626397904.html
边栏推荐
- Houdini > rigid body, rigid body breaking RBD
- ES6使用递归实现深拷贝
- 解决在docker中部署mysql8, 密码正确但无法登陆MySQL问题
- 使用flask时代码无报错自动结束,无法保持连接,访问不了url。
- Plane definition - plane equation
- IT高薪者所具备的人格魅力
- Read and modify the JSON file under the resource folder
- UnityShader基础
- The projection vector of a vector to a plane
- Double sided shader
猜你喜欢

Robust and Efficient Quadrotor Trajectory Generation for Fast Autonomous Flight

C# 多个矩形围成的多边形标注位置的问题

Install and configure Taobao image NPM (cnpm)

SQL sorts string numbers

Unity获取真实地理地图应用Terrain笔记

Shapley Explanation Networks

VBA調用SAP RFC實現數據讀取&寫入

Houdini>流体,刚体导出学习过程笔记

SVG中Path Data数据简化及文件夹所有文件批量导出为图片

使用flask时代码无报错自动结束,无法保持连接,访问不了url。
随机推荐
A programmer who works four hours a day
The projection vector of a vector to a plane
Teach-Repeat-Replan: A Complete and Robust System for Aggressive Flight in Complex Environments
Towords Open World Object Detection
双面显示的shader
Houdini>流体,刚体导出学习过程笔记
Houdini>刚体, 刚体破碎RBD
踩坑日记:Unable to process Jar entry [module-info.class]
NodeJS(一) 事件驱动编程
03Scanner类的使用(控制台输入)
Scrapy 修改爬虫结束时统计数据中的时间为当前系统时间
关于U盘数据提示RAW,需要格式化,数据恢复笔记
IT高薪者所具备的人格魅力
Weblux file upload and download
unity UGUI判断点击在UI上和3D物体上的解决方案
系统与软件安全研究(二)
Enterprise wechat login free jump self built application
Scrapy modifies the time in the statistics at the end of the crawler as the current system time
给定区段范围内字符串自生成代码
Double sided shader