ParthSadaria commited on
Commit
03de59f
·
verified ·
1 Parent(s): c67d238

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +1 -31
main.py CHANGED
@@ -171,37 +171,7 @@ def get_scraper():
171
  scraper_pool.append(cloudscraper.create_scraper())
172
  return scraper_pool[int(time.time() * 1000) % MAX_SCRAPERS]
173
 
174
- async def verify_api_key(
175
- request: Request,
176
- api_key: str = Security(api_key_header)
177
- ):
178
- referer = request.headers.get("referer", "")
179
- if referer.startswith(("https://parthsadaria-lokiai.hf.space/playground",
180
- "https://parthsadaria-lokiai.hf.space/image-playground")):
181
- return True
182
-
183
- if not api_key:
184
- raise HTTPException(
185
- status_code=HTTP_403_FORBIDDEN,
186
- detail="No API key provided"
187
- )
188
-
189
- if api_key.startswith('Bearer '):
190
- api_key = api_key[7:]
191
-
192
- valid_api_keys = get_env_vars().get('api_keys', [])
193
- if not valid_api_keys or valid_api_keys == ['']:
194
- raise HTTPException(
195
- status_code=HTTP_403_FORBIDDEN,
196
- detail="API keys not configured on server"
197
- )
198
-
199
- if api_key not in set(valid_api_keys):
200
- raise HTTPException(
201
- status_code=HTTP_403_FORBIDDEN,
202
- detail="Invalid API key"
203
- )
204
-
205
  return True
206
 
207
  @lru_cache(maxsize=1)
 
171
  scraper_pool.append(cloudscraper.create_scraper())
172
  return scraper_pool[int(time.time() * 1000) % MAX_SCRAPERS]
173
 
174
+ async def verify_api_key(request: Request, api_key: str = None):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  return True
176
 
177
  @lru_cache(maxsize=1)