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

相关推荐
何曾参静谧几秒前
「C/C++」C/C++ 之 变量作用域详解
c语言·开发语言·c++
q5673152327 分钟前
在 Bash 中获取 Python 模块变量列
开发语言·python·bash
是萝卜干呀28 分钟前
Backend - Python 爬取网页数据并保存在Excel文件中
python·excel·table·xlwt·爬取网页数据
代码欢乐豆29 分钟前
数据采集之selenium模拟登录
python·selenium·测试工具
吕彬-前端43 分钟前
使用vite+react+ts+Ant Design开发后台管理项目(五)
前端·javascript·react.js
学前端的小朱1 小时前
Redux的简介及其在React中的应用
前端·javascript·react.js·redux·store
许野平1 小时前
Rust: 利用 chrono 库实现日期和字符串互相转换
开发语言·后端·rust·字符串·转换·日期·chrono
guai_guai_guai1 小时前
uniapp
前端·javascript·vue.js·uni-app
也无晴也无风雨1 小时前
在JS中, 0 == [0] 吗
开发语言·javascript
狂奔solar1 小时前
yelp数据集上识别潜在的热门商家
开发语言·python