rogerxavier
commited on
Commit
•
bd66be8
1
Parent(s):
0b32a98
Update api.py
Browse files
api.py
CHANGED
@@ -267,7 +267,11 @@ def get_cover_image():
|
|
267 |
#请求任意图片路径就返回这个路径的图片方便随时查看
|
268 |
|
269 |
@app.get("/get_image/{directory:path}/{file_name}")
|
270 |
-
def get_image(directory: str =
|
271 |
-
|
|
|
|
|
|
|
|
|
272 |
file_path = os.path.join(image_dir, file_name)
|
273 |
return FileResponse(file_path)
|
|
|
267 |
#请求任意图片路径就返回这个路径的图片方便随时查看
|
268 |
|
269 |
@app.get("/get_image/{directory:path}/{file_name}")
|
270 |
+
def get_image(directory: str = "", file_name: str = Path(...)):
|
271 |
+
if directory:
|
272 |
+
image_dir = f"/{directory}" # 指定子目录
|
273 |
+
else:
|
274 |
+
image_dir = "" # 默认为当前目录
|
275 |
+
|
276 |
file_path = os.path.join(image_dir, file_name)
|
277 |
return FileResponse(file_path)
|