rogerxavier
commited on
Commit
•
de32832
1
Parent(s):
0c4e15c
Update api.py
Browse files
api.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from fastapi import FastAPI, File, UploadFile,Body,Query,Response
|
2 |
from fastapi.staticfiles import StaticFiles
|
3 |
from fastapi.responses import FileResponse
|
4 |
from PIL import Image
|
@@ -262,3 +262,12 @@ def get_cover_image():
|
|
262 |
cover_dir = "cover"
|
263 |
file_path = os.path.join(cover_dir, "0.jpg")
|
264 |
return FileResponse(file_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI, File, UploadFile,Body,Query,Response,Path
|
2 |
from fastapi.staticfiles import StaticFiles
|
3 |
from fastapi.responses import FileResponse
|
4 |
from PIL import Image
|
|
|
262 |
cover_dir = "cover"
|
263 |
file_path = os.path.join(cover_dir, "0.jpg")
|
264 |
return FileResponse(file_path)
|
265 |
+
|
266 |
+
|
267 |
+
#请求任意图片路径就返回这个路径的图片方便随时查看
|
268 |
+
|
269 |
+
@app.get("/{file_name}")
|
270 |
+
def get_image(file_name: str = Path(...)):
|
271 |
+
image_dir = "/"
|
272 |
+
file_path = os.path.join(image_dir, file_name)
|
273 |
+
return FileResponse(file_path)
|