1 Star 0 Fork 74

清风/FastAPI

forked from Gitee 极速下载/FastAPI 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tutorial001.py 461 Bytes
一键复制 编辑 原始数据 按行查看 历史
Sebastián Ramírez 提交于 2020-06-29 02:13 +08:00 . 📝 Use Optional in docs (#1644)
from datetime import datetime
from typing import Optional
from fastapi import FastAPI
from fastapi.encoders import jsonable_encoder
from pydantic import BaseModel
fake_db = {}
class Item(BaseModel):
title: str
timestamp: datetime
description: Optional[str] = None
app = FastAPI()
@app.put("/items/{id}")
def update_item(id: str, item: Item):
json_compatible_item_data = jsonable_encoder(item)
fake_db[id] = json_compatible_item_data
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/VIPhxp/FastAPI.git
git@gitee.com:VIPhxp/FastAPI.git
VIPhxp
FastAPI
FastAPI
master

搜索帮助