LogDisplayer / main.py
Beracles's picture
api of healthcheck
c79d28c
raw
history blame
980 Bytes
from fastapi import FastAPI, Body
from fastapi.middleware.cors import CORSMiddleware
from panel.io.fastapi import add_applications
import page
from utils import beijing
import logging
app = FastAPI(
title=f"Log Displayer",
description=f"Updated at {beijing()}",
)
print("Adding middlewares...", end="")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
print("Done\n")
add_applications(page.page, app=app, title="Log Displayer")
@app.post("/app")
async def log_app(message: str = Body(..., embed=True)):
print(f"[APP] {message}")
logger = logging.getLogger("APP")
logger.debug(message)
return True
@app.post("/game")
async def log_game(message: str = Body(..., embed=True)):
print(f"[GAME] {message}")
logger = logging.getLogger("Game")
logger.debug(message)
return True
@app.get("/healthcheck")
async def health_check():
return True