17 lines
446 B
Python
17 lines
446 B
Python
import base64
|
|
import logging
|
|
import os
|
|
|
|
import requests
|
|
|
|
from config import Config
|
|
|
|
|
|
def get_image(user_id: int) -> str:
|
|
path = os.path.join(Config().TMP_DIR, f"{user_id}.png")
|
|
if not os.path.exists(path):
|
|
logging.warn(f"Getting new image for {user_id}!")
|
|
req = requests.get(f"{Config().NFT_SVC_ADDR}/getImage").json()
|
|
with open(path, "wb") as f:
|
|
f.write(base64.b64decode(req["image"]))
|
|
return path |