nixaut-codelabs commited on
Commit
762fe84
·
verified ·
1 Parent(s): f1eeb44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,5 +1,5 @@
1
  from fastapi import FastAPI, HTTPException, Depends, status
2
- from fastapi.security import HTTPBearer, HTTPBearerToken
3
  from pydantic import BaseModel
4
  from transformers import pipeline
5
  import gradio as gr
@@ -34,13 +34,13 @@ class EnhanceRequest(BaseModel):
34
  class EnhanceResponse(BaseModel):
35
  enhanced_prompt: str
36
 
37
- def verify_api_key(token: HTTPBearerToken = Depends(security)):
38
- if token.credentials != API_KEY:
39
  raise HTTPException(
40
  status_code=status.HTTP_401_UNAUTHORIZED,
41
  detail="Invalid API key"
42
  )
43
- return token.credentials
44
 
45
  @app.post("/enhance", response_model=EnhanceResponse)
46
  async def enhance_prompt(request: EnhanceRequest, api_key: str = Depends(verify_api_key)):
 
1
  from fastapi import FastAPI, HTTPException, Depends, status
2
+ from fastapi.security import HTTPBearer
3
  from pydantic import BaseModel
4
  from transformers import pipeline
5
  import gradio as gr
 
34
  class EnhanceResponse(BaseModel):
35
  enhanced_prompt: str
36
 
37
+ def verify_api_key(credentials = Depends(security)):
38
+ if credentials.credentials != API_KEY:
39
  raise HTTPException(
40
  status_code=status.HTTP_401_UNAUTHORIZED,
41
  detail="Invalid API key"
42
  )
43
+ return credentials.credentials
44
 
45
  @app.post("/enhance", response_model=EnhanceResponse)
46
  async def enhance_prompt(request: EnhanceRequest, api_key: str = Depends(verify_api_key)):