Celeskry commited on
Commit
c988445
·
verified ·
1 Parent(s): 6ec32f4

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +29 -0
main.py CHANGED
@@ -20,15 +20,20 @@ lq_app = ClLqApp()
20
  from app.gs_daily import GSDailyApp
21
  gs_app = GSDailyApp()
22
 
 
 
 
23
  @asynccontextmanager
24
  async def lifespan(app: FastAPI):
25
  await invite_app.start()
26
  await lq_app.start()
27
  await gs_app.start()
 
28
  yield
29
  await invite_app.stop()
30
  await lq_app.stop()
31
  await gs_app.stop()
 
32
 
33
  app = FastAPI(lifespan=lifespan)
34
 
@@ -76,6 +81,30 @@ async def genshin_daily(
76
  raise HTTPException(status_code=400, detail=res["error"])
77
 
78
  return res
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  @app.get("/")
81
  def home():
 
20
  from app.gs_daily import GSDailyApp
21
  gs_app = GSDailyApp()
22
 
23
+ from app.gs_code import GSCodeApp
24
+ gs_code_app = GSCodeApp()
25
+
26
  @asynccontextmanager
27
  async def lifespan(app: FastAPI):
28
  await invite_app.start()
29
  await lq_app.start()
30
  await gs_app.start()
31
+ await gs_code_app.start()
32
  yield
33
  await invite_app.stop()
34
  await lq_app.stop()
35
  await gs_app.stop()
36
+ await gs_code_app.stop()
37
 
38
  app = FastAPI(lifespan=lifespan)
39
 
 
81
  raise HTTPException(status_code=400, detail=res["error"])
82
 
83
  return res
84
+
85
+ class RedeemRequest(BaseModel):
86
+ cookie: str
87
+ server: str
88
+ code: str
89
+
90
+ @app.post("/api/v1/genshin/redeem")
91
+ async def genshin_redeem(
92
+ data: RedeemRequest,
93
+ x_api_key: str = Header(None)
94
+ ):
95
+ if x_api_key != API_KEY:
96
+ raise HTTPException(status_code=403, detail="API key không hợp lệ")
97
+
98
+ res = await gs_code_app.redeem_code(
99
+ data.cookie,
100
+ data.server,
101
+ data.code
102
+ )
103
+
104
+ if not res["ok"]:
105
+ raise HTTPException(status_code=400, detail=res)
106
+
107
+ return res
108
 
109
  @app.get("/")
110
  def home():