slimshadow commited on
Commit
ce2b60c
·
verified ·
1 Parent(s): 8868ea9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ # Streamlit file uploader interface
5
+ st.title("File Uploader")
6
+
7
+ uploaded_file = st.file_uploader("Choose a file", type=["txt"])
8
+
9
+ if uploaded_file is not None:
10
+ # File details
11
+ file_details = {"filename": uploaded_file.name, "filetype": uploaded_file.type}
12
+ st.write(file_details)
13
+
14
+ # Define the server URL and the name under which the file will be stored
15
+ server_url = f"https://w.buzzheavier.com/t/{uploaded_file.name}"
16
+
17
+ # Send the file to the server using requests
18
+ response = requests.put(server_url, data=uploaded_file.read())
19
+
20
+ if response.status_code == 200:
21
+ # Display the response from the server
22
+ st.write("File uploaded successfully!")
23
+ st.json(response.json())
24
+ else:
25
+ st.write("Failed to upload the file.")
26
+ st.write(response.text)