Error in user YAML: (<unknown>): found a tab character that violate indentation while scanning a plain scalar at line 3 column 3
---
- oeasy Python 0613
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
- 本教程同步发布在:
- 个人网站: `https://oeasy.org`
- 蓝桥云课: `https://www.lanqiao.cn/courses/3584`
- GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
- Gitee: `https://gitee.com/overmind1980/oeasypython`
---- 我们这次要研究pythonweb
- 我们选择的是fastapi
- 我们从安装开始
pip install fastapi
pip install "uvicorn[standard]"
- 在Code中建立main.py
- 一定要进入Code编辑
- Code就是fastapi的根目录
- 如果~是fastapi根目录的话
- 启动的时候会有问题
from typing import Union
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
async def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}- 保存并尝试运行
- 注意这两个函数是平级的
- :w|!uvicorn main:app
- 提示了一个网址
- 尝试运行
- 得到了一个json文件
- 对应这个函数
- 那另一个函数呢?
- 对应另一个函数
- 这很简单
- 我们这次开启了新的旅行
- 研究fastapi这个pythonweb
- 他可以做动态网站
- 我们已经安装了这个程序
- 并且成功地跑了起来
- 可以在浏览器中访问
- fastapi为什么叫做fastapi呢?🤔
- 下次再说👋🏻
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。







