Upload 2 files
Browse files
app.py
CHANGED
|
@@ -541,7 +541,7 @@ with gr.Blocks(title="My图床", theme=gr.themes.Soft(), css=custom_css) as grad
|
|
| 541 |
)
|
| 542 |
|
| 543 |
# 在Gradio的底层FastAPI上添加自定义API路由
|
| 544 |
-
@gradio_app.
|
| 545 |
async def get_image(image_hash: str):
|
| 546 |
"""通过hash获取图片"""
|
| 547 |
try:
|
|
@@ -581,7 +581,7 @@ async def get_image(image_hash: str):
|
|
| 581 |
content={"error": str(e)}
|
| 582 |
)
|
| 583 |
|
| 584 |
-
@gradio_app.
|
| 585 |
async def get_image_info(image_hash: str, password: str = None):
|
| 586 |
"""获取图片信息(需要密码)"""
|
| 587 |
if not password or not check_password(password):
|
|
|
|
| 541 |
)
|
| 542 |
|
| 543 |
# 在Gradio的底层FastAPI上添加自定义API路由
|
| 544 |
+
@gradio_app.app.get("/api/img/{image_hash}")
|
| 545 |
async def get_image(image_hash: str):
|
| 546 |
"""通过hash获取图片"""
|
| 547 |
try:
|
|
|
|
| 581 |
content={"error": str(e)}
|
| 582 |
)
|
| 583 |
|
| 584 |
+
@gradio_app.app.get("/api/img/{image_hash}/info")
|
| 585 |
async def get_image_info(image_hash: str, password: str = None):
|
| 586 |
"""获取图片信息(需要密码)"""
|
| 587 |
if not password or not check_password(password):
|