barreloflube commited on
Commit
b1e2f28
·
1 Parent(s): 2ee83ad

refactor: switch from config to environment variables for API tokens and HF_HOME

Browse files
Files changed (2) hide show
  1. app.py +6 -6
  2. config.py +0 -3
app.py CHANGED
@@ -6,10 +6,10 @@ import tempfile
6
  import gradio as gr
7
  from PIL import Image, ImageDraw
8
 
9
- from config import config, theme
10
  from public.data.images.loras.flux1 import loras as flux1_loras
11
 
12
- # os.makedirs(config.get("HF_HOME"), exist_ok=True)
13
 
14
  # UI
15
  with gr.Blocks(
@@ -755,8 +755,8 @@ with gr.Blocks(
755
  version_id.group(1) if version_id else None
756
  )
757
 
758
- # Get API token from config
759
- api_token = config.get("CIVITAI_TOKEN")
760
  headers = (
761
  {"Authorization": f"Bearer {api_token}"}
762
  if api_token
@@ -843,8 +843,8 @@ with gr.Blocks(
843
  r"^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$", lora_selected
844
  ):
845
  try:
846
- # Get API token from config
847
- api_token = config.get("HF_TOKEN")
848
  headers = (
849
  {"Authorization": f"Bearer {api_token}"}
850
  if api_token
 
6
  import gradio as gr
7
  from PIL import Image, ImageDraw
8
 
9
+ from config import theme
10
  from public.data.images.loras.flux1 import loras as flux1_loras
11
 
12
+ os.makedirs(os.getenv("HF_HOME"), exist_ok=True)
13
 
14
  # UI
15
  with gr.Blocks(
 
755
  version_id.group(1) if version_id else None
756
  )
757
 
758
+ # Get API token from env
759
+ api_token = os.getenv("CIVITAI_TOKEN")
760
  headers = (
761
  {"Authorization": f"Bearer {api_token}"}
762
  if api_token
 
843
  r"^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$", lora_selected
844
  ):
845
  try:
846
+ # Get API token from env
847
+ api_token = os.getenv("HF_TOKEN")
848
  headers = (
849
  {"Authorization": f"Bearer {api_token}"}
850
  if api_token
config.py CHANGED
@@ -1,7 +1,4 @@
1
  import gradio as gr
2
- from starlette.config import Config
3
-
4
- config = Config(".env")
5
 
6
 
7
  theme = gr.themes.Base(
 
1
  import gradio as gr
 
 
 
2
 
3
 
4
  theme = gr.themes.Base(