python构建一个web程序

python 复制代码
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return '欢迎来到我的Python Web程序!'

if __name__ == '__main__':
    app.run(debug=True)

1、安装flask

D:\Users\USER\PycharmProjects\pythonProject1\p01>pip install flask
WARNING: Ignoring invalid distribution -ip (d:\softwares\python3.8\lib\site-packages)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting flask
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/61/80/ffe1da13ad9300f87c93af113edd0638c75138c42a0994becfacac078c06/flask-3.0.3-py3-none-any.whl (101 kB)
Collecting Werkzeug>=3.0.0 (from flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9d/6e/e792999e816d19d7fcbfa94c730936750036d65656a76a5a688b57a656c4/werkzeug-3.0.3-py3-none-any.whl (227 kB)
Collecting Jinja2>=3.1.2 (from flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/31/80/3a54838c3fb461f6fec263ebf3a3a41771bd05190238de3486aae8540c36/jinja2-3.1.4-py3-none-any.whl (133 kB)
Collecting itsdangerous>=2.1.2 (from flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl (16 kB)
Collecting click>=8.1.3 (from flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl (97 kB)
Collecting blinker>=1.6.2 (from flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bb/2a/10164ed1f31196a2f7f3799368a821765c62851ead0e630ab52b8e14b4d0/blinker-1.8.2-py3-none-any.whl (9.5 kB)
Collecting importlib-metadata>=3.6.0 (from flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/eb/e2/04e09bc7330ae906b8671bb7069e95eb7a84f14d30b25763b7acd6591ce8/importlib_metadata-8.3.0-py3-none-any.whl (2
6 kB)
Collecting colorama (from click>=8.1.3->flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting zipp>=0.5 (from importlib-metadata>=3.6.0->flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/da/cc/b9958af9f9c86b51f846d8487440af495ecf19b16e426fce1ed0b0796175/zipp-3.20.0-py3-none-any.whl (9.4 kB)
Collecting MarkupSafe>=2.0 (from Jinja2>=3.1.2->flask)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bf/f3/ecb00fc8ab02b7beae8699f34db9357ae49d9f21d4d3de6f305f34fa949e/MarkupSafe-2.1.5-cp38-cp38-win32.whl (16 kB)

WARNING: Ignoring invalid distribution -ip (d:\softwares\python3.8\lib\site-packages)
Installing collected packages: zipp, MarkupSafe, itsdangerous, colorama, blinker, Werkzeug, Jinja2, importlib-metadata, click, flask
WARNING: Ignoring invalid distribution -ip (d:\softwares\python3.8\lib\site-packages)
Successfully installed Jinja2-3.1.4 MarkupSafe-2.1.5 Werkzeug-3.0.3 blinker-1.8.2 click-8.1.7 colorama-0.4.6 flask-3.0.3 importlib-metadata-8.3.0 itsdangerous-2.2.0 zip
p-3.20.0

2、运行

3、访问web

相关推荐
彭世瑜4 分钟前
ts: TypeScript跳过检查/忽略类型检查
前端·javascript·typescript
FØund4045 分钟前
antd form.setFieldsValue问题总结
前端·react.js·typescript·html
Backstroke fish5 分钟前
Token刷新机制
前端·javascript·vue.js·typescript·vue
zwjapple5 分钟前
typescript里面正则的使用
开发语言·javascript·正则表达式
小五Five7 分钟前
TypeScript项目中Axios的封装
开发语言·前端·javascript
小曲程序7 分钟前
vue3 封装request请求
java·前端·typescript·vue
临枫5417 分钟前
Nuxt3封装网络请求 useFetch & $fetch
前端·javascript·vue.js·typescript
前端每日三省8 分钟前
面试题-TS(八):什么是装饰器(decorators)?如何在 TypeScript 中使用它们?
开发语言·前端·javascript
小刺猬_9859 分钟前
(超详细)数组方法 ——— splice( )
前端·javascript·typescript
渊兮兮10 分钟前
Vue3 + TypeScript +动画,实现动态登陆页面
前端·javascript·css·typescript·动画