Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -3,5 +3,22 @@ from fastapi import FastAPI
|
|
3 |
app = FastAPI()
|
4 |
|
5 |
@app.get("/")
|
6 |
-
def read_root():
|
7 |
-
return {"message": "Hello, World mohammad!"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
app = FastAPI()
|
4 |
|
5 |
@app.get("/")
|
6 |
+
async def read_root():
|
7 |
+
return {"message": "Hello, World mohammad!"}
|
8 |
+
|
9 |
+
|
10 |
+
# from fastapi import FastAPI
|
11 |
+
from pydantic import BaseModel
|
12 |
+
|
13 |
+
# app = FastAPI()
|
14 |
+
|
15 |
+
# Define a Pydantic model for the request body
|
16 |
+
class Item(BaseModel):
|
17 |
+
name: str
|
18 |
+
description: str = None
|
19 |
+
price: float
|
20 |
+
tax: float = None
|
21 |
+
|
22 |
+
@app.post("/items/")
|
23 |
+
def create_item(item: Item):
|
24 |
+
return {"item": item, "message": "Hello, World mohammad!"}
|