Akane710 commited on
Commit
d001f2c
·
verified ·
1 Parent(s): 87b0d98

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +23 -13
main.py CHANGED
@@ -1,6 +1,5 @@
1
  import asyncio
2
  import os
3
- from typing import Optional, Dict
4
  from enkacard import encbanner
5
  import concurrent.futures
6
  import requests
@@ -25,14 +24,14 @@ cloudinary.config(
25
  secure=True
26
  )
27
 
28
- # Genshin Impact card creation with character_art
29
- async def genshin_card(id, designtype, character_art: Optional[Dict[str, str]] = None):
30
- async with encbanner.ENC(uid=str(id), character_art=character_art) as encard:
31
  return await encard.creat(akasha=True, template=(2 if str(designtype) == "2" else 1))
32
 
33
- # Star Rail card creation with character_art
34
- async def starrail_card(id, designtype, character_art: Optional[Dict[str, str]] = None):
35
- async with starrailcard.Card(seeleland=True, remove_logo=True, character_art=character_art) as card:
36
  return await card.create(id, style=(2 if str(designtype) == "2" else 1))
37
 
38
  # Star Rail profile creation
@@ -45,11 +44,11 @@ async def genshinprofile(id):
45
  async with encbanner.ENC(uid=id) as encard:
46
  return await encard.profile(card=True)
47
 
48
- # Route for Genshin Impact with character_art
49
  @app.get("/genshin/{id}")
50
- async def genshin_characters(id: int, design: str = "1", character_art: Optional[Dict[str, str]] = None):
51
  try:
52
- result = await genshin_card(id, design, character_art)
53
  characters = process_images(result, id)
54
  return JSONResponse(content={'response': characters})
55
 
@@ -62,17 +61,28 @@ async def genshin_characters(id: int, design: str = "1", character_art: Optional
62
  except Exception as e:
63
  return JSONResponse(content={'error': 'UNKNOWN ERR: ' + str(e)}, status_code=500)
64
 
65
- # Route for Star Rail with character_art
66
  @app.get("/starrail/{id}")
67
- async def starrail_characters(id: int, design: str = "1", character_art: Optional[Dict[str, str]] = None):
68
  try:
69
- result = await starrail_card(id, design, character_art)
70
  characters = process_images(result, id)
71
  return JSONResponse(content={'response': characters})
72
 
73
  except Exception as e:
74
  return JSONResponse(content={'error': 'UNKNOWN ERR: ' + str(e)}, status_code=500)
75
 
 
 
 
 
 
 
 
 
 
 
 
76
  # Route for Genshin profile
77
  @app.get("/genshin/profile/{id}")
78
  async def genshin_profile_route(id: int):
 
1
  import asyncio
2
  import os
 
3
  from enkacard import encbanner
4
  import concurrent.futures
5
  import requests
 
24
  secure=True
25
  )
26
 
27
+ # Genshin Impact card creation
28
+ async def genshin_card(id, designtype):
29
+ async with encbanner.ENC(uid=str(id)) as encard:
30
  return await encard.creat(akasha=True, template=(2 if str(designtype) == "2" else 1))
31
 
32
+ # Star Rail card creation
33
+ async def starrail_card(id, designtype):
34
+ async with starrailcard.Card(seeleland=True, remove_logo=True) as card:
35
  return await card.create(id, style=(2 if str(designtype) == "2" else 1))
36
 
37
  # Star Rail profile creation
 
44
  async with encbanner.ENC(uid=id) as encard:
45
  return await encard.profile(card=True)
46
 
47
+ # Route for Genshin Impact
48
  @app.get("/genshin/{id}")
49
+ async def genshin_characters(id: int, design: str = "1"):
50
  try:
51
+ result = await genshin_card(id, design)
52
  characters = process_images(result, id)
53
  return JSONResponse(content={'response': characters})
54
 
 
61
  except Exception as e:
62
  return JSONResponse(content={'error': 'UNKNOWN ERR: ' + str(e)}, status_code=500)
63
 
64
+ # Route for Star Rail
65
  @app.get("/starrail/{id}")
66
+ async def starrail_characters(id: int, design: str = "1"):
67
  try:
68
+ result = await starrail_card(id, design)
69
  characters = process_images(result, id)
70
  return JSONResponse(content={'response': characters})
71
 
72
  except Exception as e:
73
  return JSONResponse(content={'error': 'UNKNOWN ERR: ' + str(e)}, status_code=500)
74
 
75
+ # Route for Star Rail profile
76
+ @app.get("/starrail/profile/{id}")
77
+ async def starrail_profile_route(id: int):
78
+ try:
79
+ result = await starrail_profile(id)
80
+ profile_data = process_profile(result)
81
+ return JSONResponse(content={'response': profile_data})
82
+
83
+ except Exception as e:
84
+ return JSONResponse(content={'error': 'UNKNOWN ERR: ' + str(e)}, status_code=500)
85
+
86
  # Route for Genshin profile
87
  @app.get("/genshin/profile/{id}")
88
  async def genshin_profile_route(id: int):