Update main.py
Browse files
main.py
CHANGED
@@ -56,6 +56,10 @@ app.add_middleware(
|
|
56 |
|
57 |
@app.post("/generate/")
|
58 |
async def generate(request: Request):
|
|
|
|
|
|
|
|
|
59 |
form = await request.form()
|
60 |
prompt = form.get("prompt")
|
61 |
history = json.loads(form.get("history", "[]")) # Default to empty history
|
|
|
56 |
|
57 |
@app.post("/generate/")
|
58 |
async def generate(request: Request):
|
59 |
+
allowed_origin = "https://artixiban-ll3.static.hf.space"
|
60 |
+
origin = request.headers.get("origin")
|
61 |
+
if origin != allowed_origin:
|
62 |
+
raise HTTPException(status_code=403, detail="Origin not allowed")
|
63 |
form = await request.form()
|
64 |
prompt = form.get("prompt")
|
65 |
history = json.loads(form.get("history", "[]")) # Default to empty history
|