12345678910111213141516171819202122232425262728293031 |
- import uvicorn
- import fastapi
- from fastapi.middleware.cors import CORSMiddleware
- import models
- app = fastapi.FastAPI()
- app.add_middleware(
- CORSMiddleware,
- allow_origins=['*'],
- allow_credentials=True,
- allow_methods=["*"],
- allow_headers=["*"],
- )
- @app.post("/callevent")
- async def callevent(userModel: models.callBack):
- """
- 事件會用application/json和POST方式打到指定位址, 內容基本包含
- {
- "type": "xxx", // 事件類型, 字串
- "data": {} // 事件內容資料
- }
- """
- str1 = userModel.type
- dict1 = userModel.data
- result = str1, dict1
- return result
- if __name__ == '__main__':
- uvicorn.run("call:app", host="0.0.0.0", port=5000, reload=True)
|