Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -34,9 +34,16 @@ app.layout = dbc.Container([
|
|
34 |
},
|
35 |
multiple=False
|
36 |
),
|
|
|
37 |
dbc.Input(id="url-input", placeholder="Or enter PDF URL", type="text", className="mt-3"),
|
38 |
dbc.Button("Compress PDF", id="compress-btn", color="primary", className="mt-3"),
|
39 |
-
dbc.Spinner(
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
dcc.Download(id="download-pdf"),
|
41 |
])
|
42 |
]),
|
@@ -82,6 +89,18 @@ def compress_pdf(input_file, url):
|
|
82 |
except Exception as e:
|
83 |
return None, f"Error compressing PDF: {str(e)}"
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
@callback(
|
86 |
Output("compression-status", "children"),
|
87 |
Output("download-pdf", "data"),
|
|
|
34 |
},
|
35 |
multiple=False
|
36 |
),
|
37 |
+
dbc.Alert(id="upload-status", is_open=False, duration=4000, className="mt-3"),
|
38 |
dbc.Input(id="url-input", placeholder="Or enter PDF URL", type="text", className="mt-3"),
|
39 |
dbc.Button("Compress PDF", id="compress-btn", color="primary", className="mt-3"),
|
40 |
+
dbc.Spinner(
|
41 |
+
html.Div(id="compression-status", className="mt-3"),
|
42 |
+
color="primary",
|
43 |
+
type="border",
|
44 |
+
fullscreen=True,
|
45 |
+
fullscreen_style={"backgroundColor": "rgba(0, 0, 0, 0.3)"},
|
46 |
+
),
|
47 |
dcc.Download(id="download-pdf"),
|
48 |
])
|
49 |
]),
|
|
|
89 |
except Exception as e:
|
90 |
return None, f"Error compressing PDF: {str(e)}"
|
91 |
|
92 |
+
@callback(
|
93 |
+
Output("upload-status", "children"),
|
94 |
+
Output("upload-status", "is_open"),
|
95 |
+
Output("upload-status", "color"),
|
96 |
+
Input("upload-pdf", "filename"),
|
97 |
+
Input("upload-pdf", "contents"),
|
98 |
+
)
|
99 |
+
def update_upload_status(filename, contents):
|
100 |
+
if filename is not None and contents is not None:
|
101 |
+
return f"File uploaded: {filename}", True, "success"
|
102 |
+
return "", False, "primary"
|
103 |
+
|
104 |
@callback(
|
105 |
Output("compression-status", "children"),
|
106 |
Output("download-pdf", "data"),
|