Hana Celeste commited on
Commit
00dbde6
·
verified ·
1 Parent(s): 0d18fcb

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -0
main.py CHANGED
@@ -1,13 +1,17 @@
1
  from fastapi import FastAPI
2
  from contextlib import asynccontextmanager
3
  from app.enka_logic import EnkaApp
 
4
 
5
  enka = EnkaApp()
 
6
 
7
  @asynccontextmanager
8
  async def lifespan(app: FastAPI):
9
  await enka.start()
 
10
  yield
 
11
  await enka.stop()
12
 
13
  app = FastAPI(lifespan=lifespan)
@@ -20,6 +24,10 @@ async def get_info(uid: str):
20
  async def get_gen(uid: str, char: str = None):
21
  return await enka.fetch_gen(uid, char)
22
 
 
 
 
 
23
  @app.get("/")
24
  def home():
25
  return {"status": "Modular API is Live", "logic": "Loaded from ./app/enka_logic.py"}
 
1
  from fastapi import FastAPI
2
  from contextlib import asynccontextmanager
3
  from app.enka_logic import EnkaApp
4
+ from app.fetch import Fetcher
5
 
6
  enka = EnkaApp()
7
+ fetcher = Fetcher()
8
 
9
  @asynccontextmanager
10
  async def lifespan(app: FastAPI):
11
  await enka.start()
12
+ await fetcher.start()
13
  yield
14
+ await fetcher.stop()
15
  await enka.stop()
16
 
17
  app = FastAPI(lifespan=lifespan)
 
24
  async def get_gen(uid: str, char: str = None):
25
  return await enka.fetch_gen(uid, char)
26
 
27
+ @app.get("/fetch")
28
+ async def fetch_url(url: str):
29
+ return await fetcher.fetch(url)
30
+
31
  @app.get("/")
32
  def home():
33
  return {"status": "Modular API is Live", "logic": "Loaded from ./app/enka_logic.py"}