Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,24 @@
|
|
| 1 |
from fastapi import FastAPI
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
@app.get("/")
|
| 6 |
def greet_json():
|
| 7 |
return {"Hello": "World!"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
|
| 4 |
+
# Define the ticket schema using Pydantic
|
| 5 |
+
class Ticket(BaseModel):
|
| 6 |
+
name: str
|
| 7 |
+
department: str
|
| 8 |
+
category: str
|
| 9 |
+
description: str
|
| 10 |
+
service_category: str
|
| 11 |
+
difficulty: int # Adjust type as needed (e.g., int or str)
|
| 12 |
|
| 13 |
@app.get("/")
|
| 14 |
def greet_json():
|
| 15 |
return {"Hello": "World!"}
|
| 16 |
+
|
| 17 |
+
@app.post("/ticket")
|
| 18 |
+
async def create_ticket(ticket: Ticket):
|
| 19 |
+
# Here you can process the ticket, e.g., save it to a database.
|
| 20 |
+
# For now, we simply return the received ticket data.
|
| 21 |
+
return {
|
| 22 |
+
"message": "Ticket created successfully",
|
| 23 |
+
"ticket": ticket.dict()
|
| 24 |
+
}
|