Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,25 +18,23 @@ if uploaded_file is not None:
|
|
| 18 |
# Send the file to the server using requests
|
| 19 |
response = requests.put(server_url, data=uploaded_file.read())
|
| 20 |
|
| 21 |
-
# Check
|
| 22 |
if response.status_code == 200:
|
| 23 |
try:
|
| 24 |
-
# Parse the response
|
| 25 |
-
|
| 26 |
-
file_id =
|
| 27 |
-
|
| 28 |
if file_id:
|
| 29 |
-
# Display success message and file link
|
| 30 |
st.write("File uploaded successfully!")
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
else:
|
| 34 |
-
st.write("File uploaded, but
|
| 35 |
-
st.write(response.text)
|
| 36 |
except ValueError:
|
| 37 |
-
|
| 38 |
-
st.write("Failed to parse the server response.")
|
| 39 |
-
st.write(response.text)
|
| 40 |
else:
|
|
|
|
| 41 |
st.write("Failed to upload the file.")
|
| 42 |
st.write(response.text)
|
|
|
|
| 18 |
# Send the file to the server using requests
|
| 19 |
response = requests.put(server_url, data=uploaded_file.read())
|
| 20 |
|
| 21 |
+
# Check the response status code and content
|
| 22 |
if response.status_code == 200:
|
| 23 |
try:
|
| 24 |
+
# Parse the JSON response to get the file ID
|
| 25 |
+
response_data = response.json()
|
| 26 |
+
file_id = response_data.get("id")
|
| 27 |
+
|
| 28 |
if file_id:
|
|
|
|
| 29 |
st.write("File uploaded successfully!")
|
| 30 |
+
# Provide a direct link to the uploaded file
|
| 31 |
+
file_link = f"https://buzzheavier.com/f/{file_id}"
|
| 32 |
+
st.markdown(f"[View your uploaded file here]({file_link})")
|
| 33 |
else:
|
| 34 |
+
st.write("File uploaded, but could not retrieve file ID.")
|
|
|
|
| 35 |
except ValueError:
|
| 36 |
+
st.write("File uploaded, but received an invalid response.")
|
|
|
|
|
|
|
| 37 |
else:
|
| 38 |
+
# Display the error response from the server
|
| 39 |
st.write("Failed to upload the file.")
|
| 40 |
st.write(response.text)
|