Flask开发(一)Pycharm建立项目

1 pycharm建立虚拟环境

 

2 打开项目并使用虚拟环境

 

 

 

3 安装Flask

 

 

 

 安装好之后多了这些包

 

 

 

4  建立初始测试

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
   return 'Hello World, Flask_dev'

if __name__ == '__main__':
   app.run(host='0.0.0.0', port=8080, debug=True)

 

debug=True 打印调试信息,并且代码修改时自动重启

D:\Work\projects\python_projects\flask_dev\venv\Scripts\python.exe D:/Work/projects/python_projects/flask_dev/Hello.py
 * Serving Flask app 'Hello' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 117-811-196
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://10.0.1.39:8080/ (Press CTRL+C to quit)
 * Detected change in 'D:\\Work\\projects\\python_projects\\flask_dev\\Hello.py', reloading  自动检测代码修改
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 117-811-196
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://10.0.1.39:8080/ (Press CTRL+C to quit)

 

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
return 'Hello World, Flask_dev'

if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080, debug=True)
posted @ 2021-10-29 18:04  AdamTang  阅读(333)  评论(0编辑  收藏  举报