Spaces:
Running
Running
change request body schema
Browse files
main.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
|
|
|
| 2 |
from panel.io.fastapi import add_applications
|
| 3 |
from page import page
|
| 4 |
import logging
|
|
@@ -6,16 +7,18 @@ import logging
|
|
| 6 |
app = FastAPI()
|
| 7 |
add_applications(page, app=app)
|
| 8 |
|
|
|
|
|
|
|
| 9 |
|
| 10 |
@app.post("/app")
|
| 11 |
-
async def log_app(
|
| 12 |
logger = logging.getLogger("APP")
|
| 13 |
-
logger.debug(message)
|
| 14 |
return {"details": "Logged Successfully. Please check the root page."}
|
| 15 |
|
| 16 |
|
| 17 |
@app.post("/game")
|
| 18 |
-
async def log_game(
|
| 19 |
logger = logging.getLogger("Game")
|
| 20 |
-
logger.debug(message)
|
| 21 |
return {"details": "Logged Successfully. Please check the root page."}
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
from panel.io.fastapi import add_applications
|
| 4 |
from page import page
|
| 5 |
import logging
|
|
|
|
| 7 |
app = FastAPI()
|
| 8 |
add_applications(page, app=app)
|
| 9 |
|
| 10 |
+
class Log(BaseModel):
|
| 11 |
+
message: str
|
| 12 |
|
| 13 |
@app.post("/app")
|
| 14 |
+
async def log_app(log: Log):
|
| 15 |
logger = logging.getLogger("APP")
|
| 16 |
+
logger.debug(log.message)
|
| 17 |
return {"details": "Logged Successfully. Please check the root page."}
|
| 18 |
|
| 19 |
|
| 20 |
@app.post("/game")
|
| 21 |
+
async def log_game(log: Log):
|
| 22 |
logger = logging.getLogger("Game")
|
| 23 |
+
logger.debug(log.message)
|
| 24 |
return {"details": "Logged Successfully. Please check the root page."}
|