Spaces:
Runtime error
Runtime error
print reques
Browse files
app.py
CHANGED
|
@@ -94,7 +94,6 @@ def generate(
|
|
| 94 |
app = FastAPI()
|
| 95 |
origins = [
|
| 96 |
"http://huggingface.co",
|
| 97 |
-
"localhost",
|
| 98 |
]
|
| 99 |
|
| 100 |
app.add_middleware(
|
|
@@ -108,7 +107,7 @@ app.add_middleware(
|
|
| 108 |
|
| 109 |
@app.middleware("http")
|
| 110 |
async def validate_origin(request: Request, call_next):
|
| 111 |
-
logging.info(f"Request origin: {request.headers
|
| 112 |
if request.headers.get("origin") not in origins:
|
| 113 |
raise HTTPException(status_code=403, detail="Forbidden")
|
| 114 |
response = await call_next(request)
|
|
@@ -116,7 +115,7 @@ async def validate_origin(request: Request, call_next):
|
|
| 116 |
|
| 117 |
|
| 118 |
@app.get("/image")
|
| 119 |
-
async def generate_image(prompt: str, negative_prompt: str, seed: int = 2134213213):
|
| 120 |
cached_img = database.check(prompt, negative_prompt, seed)
|
| 121 |
if cached_img:
|
| 122 |
logging.info(f"Image found in cache: {cached_img[0]}")
|
|
|
|
| 94 |
app = FastAPI()
|
| 95 |
origins = [
|
| 96 |
"http://huggingface.co",
|
|
|
|
| 97 |
]
|
| 98 |
|
| 99 |
app.add_middleware(
|
|
|
|
| 107 |
|
| 108 |
@app.middleware("http")
|
| 109 |
async def validate_origin(request: Request, call_next):
|
| 110 |
+
logging.info(f"Request origin: {request.headers}")
|
| 111 |
if request.headers.get("origin") not in origins:
|
| 112 |
raise HTTPException(status_code=403, detail="Forbidden")
|
| 113 |
response = await call_next(request)
|
|
|
|
| 115 |
|
| 116 |
|
| 117 |
@app.get("/image")
|
| 118 |
+
async def generate_image(prompt: str, negative_prompt: str = "", seed: int = 2134213213):
|
| 119 |
cached_img = database.check(prompt, negative_prompt, seed)
|
| 120 |
if cached_img:
|
| 121 |
logging.info(f"Image found in cache: {cached_img[0]}")
|