Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,19 @@
|
|
| 1 |
-
import
|
| 2 |
-
import
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
# Send file to the private Space API
|
| 21 |
-
files = {"file": uploaded_file.getvalue()}
|
| 22 |
-
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
| 23 |
-
|
| 24 |
-
try:
|
| 25 |
-
response = requests.post(PRIVATE_SPACE_URL, files=files, headers=headers)
|
| 26 |
-
|
| 27 |
-
if response.status_code == 200:
|
| 28 |
-
st.success("✅ Private Space processed the file successfully!")
|
| 29 |
-
st.write(response.json()) # Display results
|
| 30 |
-
else:
|
| 31 |
-
st.error(f"❌ Error: {response.status_code} - {response.text}")
|
| 32 |
-
|
| 33 |
-
except requests.exceptions.RequestException as e:
|
| 34 |
-
st.error(f"🚨 Request failed: {e}")
|
|
|
|
| 1 |
+
from huggingface_hub import hf_hub_download , snapshot_download
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import importlib
|
| 4 |
+
# snapshot_downloading your private space
|
| 5 |
+
snapshot_download(
|
| 6 |
+
repo_id="wintergw/assignment_opt_gurobi",
|
| 7 |
+
repo_type="space",
|
| 8 |
+
cache_dir="private_space_cache"
|
| 9 |
+
)
|
| 10 |
+
# calling the app code
|
| 11 |
+
app = hf_hub_download(
|
| 12 |
+
repo_id="wintergw/assignment_opt_gurobi",
|
| 13 |
+
filename="app.py",
|
| 14 |
+
repo_type="space"
|
| 15 |
+
)
|
| 16 |
+
# executing the app file
|
| 17 |
+
spec_app = importlib.util.spec_from_file_location("*",app_path)
|
| 18 |
+
app = importlib.util.module_from_spec(spec_app)
|
| 19 |
+
spec_app.loader.exec_module(app)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|