Compare commits

...

2 Commits

Author SHA1 Message Date
panda 590e849fd9 fast_api 探索 2025-12-16 10:52:57 +08:00
panda 1f8b52cf45 flask数据库 2025-11-07 14:19:19 +08:00
3 changed files with 61 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "initial_id",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": ""
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
+25
View File
@@ -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}
+1
View File
@@ -11,6 +11,7 @@
<sourceFolder url="file://$MODULE_DIR$/python爬虫/python爬虫练习/wangyizhaopin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/python爬虫/python爬虫练习/douban" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/flask框架" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/Fastapi" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/python爬虫/python爬虫练习/novel" />
</content>
<orderEntry type="jdk" jdkName="python" jdkType="Python SDK" />