Hana Celeste commited on
Commit
b5d3bc8
·
verified ·
1 Parent(s): 41c37b5

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -4
main.py CHANGED
@@ -6,12 +6,14 @@ from app.akasa_logic import AkasaApp
6
  from app.fetch import Fetcher
7
  from app.discord_logic import DiscordApp
8
  from app.byps_logic import BypsApp
 
9
 
10
  enka = EnkaApp()
11
  akasa = AkasaApp()
12
  fetcher = Fetcher()
13
  discord_app = DiscordApp()
14
  byps = BypsApp()
 
15
 
16
  @asynccontextmanager
17
  async def lifespan(app: FastAPI):
@@ -20,12 +22,14 @@ async def lifespan(app: FastAPI):
20
  await fetcher.start()
21
  await discord_app.start()
22
  await byps.start()
 
23
  yield
24
- await fetcher.stop()
25
- await akasa.stop()
26
- await enka.stop()
27
- await discord_app.stop()
28
  await byps.stop()
 
 
 
 
29
 
30
  app = FastAPI(lifespan=lifespan)
31
 
@@ -52,6 +56,15 @@ async def get_discord_info(uid: str):
52
  @app.get("/api/byps")
53
  async def api_bypass(url: str):
54
  return await byps.fetch(url)
 
 
 
 
 
 
 
 
 
55
 
56
  @app.get("/")
57
  def home():
 
6
  from app.fetch import Fetcher
7
  from app.discord_logic import DiscordApp
8
  from app.byps_logic import BypsApp
9
+ from app.gscode_logic import GscodeApp
10
 
11
  enka = EnkaApp()
12
  akasa = AkasaApp()
13
  fetcher = Fetcher()
14
  discord_app = DiscordApp()
15
  byps = BypsApp()
16
+ gscode = GscodeApp()
17
 
18
  @asynccontextmanager
19
  async def lifespan(app: FastAPI):
 
22
  await fetcher.start()
23
  await discord_app.start()
24
  await byps.start()
25
+ await gscode.start()
26
  yield
27
+ await gscode.stop()
 
 
 
28
  await byps.stop()
29
+ await discord_app.stop()
30
+ await enka.stop()
31
+ await akasa.stop()
32
+ await fetcher.stop()
33
 
34
  app = FastAPI(lifespan=lifespan)
35
 
 
56
  @app.get("/api/byps")
57
  async def api_bypass(url: str):
58
  return await byps.fetch(url)
59
+
60
+ @app.get("/genshin-codes")
61
+ async def genshin_codes(
62
+ url: str = Query(..., description="URL chứa Genshin redeem codes")
63
+ ):
64
+ try:
65
+ return await gscode.fetch_codes(url)
66
+ except Exception as e:
67
+ raise HTTPException(status_code=500, detail=str(e))
68
 
69
  @app.get("/")
70
  def home():