From 590e849fd96a40e1f2f5a3e50882d1271dc0f602 Mon Sep 17 00:00:00 2001
From: z66 <1415243231@qq.com>
Date: Tue, 16 Dec 2025 10:52:57 +0800
Subject: [PATCH] =?UTF-8?q?fast=5Fapi=20=E6=8E=A2=E7=B4=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Fastapi/fastapi_1.ipynb | 4 +---
Fastapi/fastapi_1.py | 25 +++++++++++++++++++++++++
python.iml | 1 +
3 files changed, 27 insertions(+), 3 deletions(-)
create mode 100644 Fastapi/fastapi_1.py
diff --git a/Fastapi/fastapi_1.ipynb b/Fastapi/fastapi_1.ipynb
index 54f657b..5362e82 100644
--- a/Fastapi/fastapi_1.ipynb
+++ b/Fastapi/fastapi_1.ipynb
@@ -8,9 +8,7 @@
"collapsed": true
},
"outputs": [],
- "source": [
- ""
- ]
+ "source": ""
}
],
"metadata": {
diff --git a/Fastapi/fastapi_1.py b/Fastapi/fastapi_1.py
new file mode 100644
index 0000000..4c7826a
--- /dev/null
+++ b/Fastapi/fastapi_1.py
@@ -0,0 +1,25 @@
+from typing import Union
+from fastapi import FastAPI
+from pydantic import BaseModel
+
+app = FastAPI()
+
+class Item(BaseModel):
+ name: str
+ price: float
+ is_offer: Union[bool, None] = None
+
+@app.get("/")
+def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+def read_item(item_id: int, q: Union[str, None] = None):
+ return {"item_id": item_id, "q": q}
+
+
+@app.put("/items/{item_id}")
+def update_item(item_id: int, item: Item):
+ return {"item_name": item.price, "item_id": item_id}
+
diff --git a/python.iml b/python.iml
index d6a0489..5d6e011 100644
--- a/python.iml
+++ b/python.iml
@@ -11,6 +11,7 @@
+