Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -54,15 +54,14 @@ def generate(item: Item):
|
|
54 |
return output
|
55 |
|
56 |
@app.post("/generate/")
|
57 |
-
async def generate_text(item: Item):
|
58 |
# Reject if not authenticated
|
59 |
apiKey = os.environ.get("API_KEY")
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
"
|
64 |
-
|
65 |
-
}), 401
|
66 |
|
67 |
return {
|
68 |
"response": generate(item)
|
|
|
54 |
return output
|
55 |
|
56 |
@app.post("/generate/")
|
57 |
+
async def generate_text(item: Item, authorization: str = Header(None)):
|
58 |
# Reject if not authenticated
|
59 |
apiKey = os.environ.get("API_KEY")
|
60 |
+
if not authorization or not authorization.startswith('Bearer ' + apiKey):
|
61 |
+
raise HTTPException(
|
62 |
+
status_code=401,
|
63 |
+
detail="Invalid or missing Bearer token"
|
64 |
+
)
|
|
|
65 |
|
66 |
return {
|
67 |
"response": generate(item)
|