|
from fastapi import FastAPI, HTTPException, Request |
|
from fastapi.middleware.cors import CORSMiddleware |
|
import json |
|
app = FastAPI() |
|
@app.post("/get_callback") |
|
async def get_callback(request: Request): |
|
try: |
|
json_data = await request.json() |
|
challenge = json_data.get("challenge") |
|
if challenge is not None: |
|
|
|
return {"challenge": challenge} |
|
else: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {"status": "success"} |
|
except Exception as e: |
|
raise HTTPException(status_code=500, detail=str(e)) |
|
if __name__ == "__main__": |
|
import uvicorn |
|
uvicorn.run( |
|
app, |
|
host="0.0.0.0", |
|
port=8000, |
|
|
|
|
|
) |