organize
This commit is contained in:
parent
68c200f686
commit
07bcac7918
1 changed files with 28 additions and 0 deletions
28
api/cartman.py
Executable file
28
api/cartman.py
Executable file
|
@ -0,0 +1,28 @@
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
|
from src.models import Packet, BotResponse
|
||||||
|
from src.bots.cartman import cartman
|
||||||
|
|
||||||
|
|
||||||
|
api = FastAPI()
|
||||||
|
|
||||||
|
api.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=['*'],
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@api.post('/chat/')
|
||||||
|
async def receive_packet(packet: Packet) -> BotResponse:
|
||||||
|
match packet.bot_name:
|
||||||
|
case 'cartman':
|
||||||
|
return cartman(packet)
|
||||||
|
case _:
|
||||||
|
return BotResponse(
|
||||||
|
name='Error',
|
||||||
|
message='bot_name is invalid'
|
||||||
|
)
|
Loading…
Add table
Reference in a new issue