Spaces:
Running
Running
added folder
Browse files
comic_panel_extractor/server.py
CHANGED
|
@@ -122,16 +122,17 @@ async def convert_comic(file: UploadFile = File(...)):
|
|
| 122 |
return {
|
| 123 |
"success": True,
|
| 124 |
"message": f"Extracted {len(all_panel_path)} panels",
|
| 125 |
-
"panels": all_panel_path
|
|
|
|
| 126 |
}
|
| 127 |
|
| 128 |
except Exception as e:
|
| 129 |
print(f"Error processing image: {str(e)} {traceback.format_exc()}")
|
| 130 |
raise HTTPException(status_code=500, detail=f"Error processing image: {str(e)} {traceback.format_exc()}")
|
| 131 |
|
| 132 |
-
@app.get("/api_outputs/{
|
| 133 |
async def get_output_file(folder: str, filename: str):
|
| 134 |
-
file_path = os.path.join(
|
| 135 |
if not os.path.exists(file_path):
|
| 136 |
raise HTTPException(status_code=404, detail="File not found")
|
| 137 |
return FileResponse(file_path)
|
|
|
|
| 122 |
return {
|
| 123 |
"success": True,
|
| 124 |
"message": f"Extracted {len(all_panel_path)} panels",
|
| 125 |
+
"panels": all_panel_path,
|
| 126 |
+
"folder": specific_output_folder
|
| 127 |
}
|
| 128 |
|
| 129 |
except Exception as e:
|
| 130 |
print(f"Error processing image: {str(e)} {traceback.format_exc()}")
|
| 131 |
raise HTTPException(status_code=500, detail=f"Error processing image: {str(e)} {traceback.format_exc()}")
|
| 132 |
|
| 133 |
+
@app.get("/api_outputs/{filename}")
|
| 134 |
async def get_output_file(folder: str, filename: str):
|
| 135 |
+
file_path = os.path.join(folder, filename)
|
| 136 |
if not os.path.exists(file_path):
|
| 137 |
raise HTTPException(status_code=404, detail="File not found")
|
| 138 |
return FileResponse(file_path)
|
comic_panel_extractor/static/index.html
CHANGED
|
@@ -428,7 +428,7 @@
|
|
| 428 |
|
| 429 |
if (data.success) {
|
| 430 |
showMessage(data.message, 'success');
|
| 431 |
-
displayPanels(data.panels);
|
| 432 |
} else {
|
| 433 |
showMessage(data.message || 'An error occurred', 'error');
|
| 434 |
}
|
|
@@ -479,7 +479,7 @@
|
|
| 479 |
}
|
| 480 |
});
|
| 481 |
|
| 482 |
-
function displayPanels(panels) {
|
| 483 |
panelsGrid.innerHTML = '';
|
| 484 |
|
| 485 |
if (panels.length === 0) {
|
|
@@ -494,7 +494,7 @@
|
|
| 494 |
panelCard.innerHTML = `
|
| 495 |
<img src="${panel}" alt="Panel ${index + 1}" onclick="openModal('${panel}')">
|
| 496 |
<div class="panel-title">Panel ${index + 1}</div>
|
| 497 |
-
<a href="${panel}" download="${panel}" class="panel-download">
|
| 498 |
Download
|
| 499 |
</a>
|
| 500 |
`;
|
|
|
|
| 428 |
|
| 429 |
if (data.success) {
|
| 430 |
showMessage(data.message, 'success');
|
| 431 |
+
displayPanels(data.panels, data.folder);
|
| 432 |
} else {
|
| 433 |
showMessage(data.message || 'An error occurred', 'error');
|
| 434 |
}
|
|
|
|
| 479 |
}
|
| 480 |
});
|
| 481 |
|
| 482 |
+
function displayPanels(panels, folder) {
|
| 483 |
panelsGrid.innerHTML = '';
|
| 484 |
|
| 485 |
if (panels.length === 0) {
|
|
|
|
| 494 |
panelCard.innerHTML = `
|
| 495 |
<img src="${panel}" alt="Panel ${index + 1}" onclick="openModal('${panel}')">
|
| 496 |
<div class="panel-title">Panel ${index + 1}</div>
|
| 497 |
+
<a href="${panel}?folder=${folder}" download="${panel}?folder=${folder}" class="panel-download">
|
| 498 |
Download
|
| 499 |
</a>
|
| 500 |
`;
|