Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,18 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_drawable_canvas import st_canvas
|
| 3 |
-
|
| 4 |
-
from dropbox.files import WriteMode
|
| 5 |
-
|
| 6 |
from PIL import Image
|
| 7 |
import numpy as np
|
| 8 |
import cv2
|
| 9 |
import hashlib
|
| 10 |
-
import
|
| 11 |
import time
|
| 12 |
import hmac
|
| 13 |
import os
|
| 14 |
st.set_page_config(layout="wide")
|
| 15 |
-
dbx = dropbox.Dropbox(st.secrets["dbx"])
|
| 16 |
password = st.secrets["dbx"]
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
if not os.path.exists("data"):
|
| 19 |
os.mkdir("data")
|
| 20 |
|
|
@@ -112,12 +110,6 @@ def check_password():
|
|
| 112 |
st.error("π Password incorrect")
|
| 113 |
return False
|
| 114 |
|
| 115 |
-
def backup(LOCALFILE, BACKUPPATH):
|
| 116 |
-
with open(LOCALFILE, 'rb') as f:
|
| 117 |
-
# We use WriteMode=overwrite to make sure that the settings in the file
|
| 118 |
-
# are changed on upload
|
| 119 |
-
print("Uploading " + LOCALFILE + " to Dropbox as " + BACKUPPATH + "...")
|
| 120 |
-
dbx.files_upload(f.read(), BACKUPPATH, mode=WriteMode('overwrite'))
|
| 121 |
|
| 122 |
st.title("IB Geography Survey")
|
| 123 |
|
|
@@ -149,10 +141,8 @@ if st.button("Save"):
|
|
| 149 |
mask = fill_enclosed_areas(mask)
|
| 150 |
cur = generate_short_hash()
|
| 151 |
cv2.imwrite(f"data/{cur}.png", mask)
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
# st.markdown(uploaded_image.link)
|
| 155 |
-
backup(f"data/{cur}.png", f"/geo/{cur}.png")
|
| 156 |
else:
|
| 157 |
st.warning("Please draw on the image.")
|
| 158 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_drawable_canvas import st_canvas
|
|
|
|
|
|
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
import numpy as np
|
| 5 |
import cv2
|
| 6 |
import hashlib
|
| 7 |
+
import pyimgur
|
| 8 |
import time
|
| 9 |
import hmac
|
| 10 |
import os
|
| 11 |
st.set_page_config(layout="wide")
|
|
|
|
| 12 |
password = st.secrets["dbx"]
|
| 13 |
+
im = pyimgur.Imgur(
|
| 14 |
+
"253ebfef9de391c"
|
| 15 |
+
)
|
| 16 |
if not os.path.exists("data"):
|
| 17 |
os.mkdir("data")
|
| 18 |
|
|
|
|
| 110 |
st.error("π Password incorrect")
|
| 111 |
return False
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
st.title("IB Geography Survey")
|
| 115 |
|
|
|
|
| 141 |
mask = fill_enclosed_areas(mask)
|
| 142 |
cur = generate_short_hash()
|
| 143 |
cv2.imwrite(f"data/{cur}.png", mask)
|
| 144 |
+
uploaded_image = im.upload_image(f"data/{cur}.png", title=f"Data Backup [GEOIA2024] {cur}")
|
| 145 |
+
print(uploaded_image.link)
|
|
|
|
|
|
|
| 146 |
else:
|
| 147 |
st.warning("Please draw on the image.")
|
| 148 |
|