DJ-Goanna-Coding commited on
Commit
d7cd26a
·
verified ·
1 Parent(s): 58aeb55

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +29 -11
app.py CHANGED
@@ -1,15 +1,33 @@
1
- import streamlit as st
2
  import os
 
 
 
 
 
 
 
3
 
4
- st.set_page_config(page_title="Citadel Recovery", page_icon="🏛️")
5
- st.title("🏛️ Node Recovery: Active")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- # Self-Diagnostic
8
- st.write("### 🛠️ System Check")
9
- st.write(f"Stability: $9,293$")
10
- if os.environ.get("GDRIVE_SERVICE_ACCOUNT_JSON"):
11
- st.success("✅ Service Badge Detected")
12
- else:
13
- st.warning("⚠️ Service Badge Missing - Check Secrets")
14
 
15
- st.info("Awaiting Logic Shard Ingestion from Librarian...")
 
 
1
+
2
  import os
3
+ from flask import Flask, request, jsonify
4
+ from huggingface_hub import HfApi
5
+
6
+ app = Flask(__name__)
7
+ TOKEN = os.getenv("HF_TOKEN")
8
+ VAULT_ID = "DJ-Goanna-Coding/Mapping-and-Inventory-storage" # All feed the Librarian Vault
9
+ api = HfApi(token=TOKEN)
10
 
11
+ @app.route('/ignite_harvest', methods=['POST'])
12
+ def catch_payload():
13
+ if not TOKEN:
14
+ return jsonify({"status": "ERROR", "message": "HF_TOKEN missing"}), 500
15
+ try:
16
+ payload = request.json
17
+ filename = payload.get("fileName", "swarm_shard.9293")
18
+ api.upload_file(
19
+ path_or_fileobj=payload.get("content", "").encode('utf-8'),
20
+ path_in_repo=f"ingested_core/{filename}",
21
+ repo_id=VAULT_ID,
22
+ repo_type="dataset"
23
+ )
24
+ return jsonify({"status": "CAUGHT_BY_SWARM", "file": filename}), 200
25
+ except Exception as e:
26
+ return jsonify({"status": "ERROR", "message": str(e)}), 500
27
 
28
+ @app.route('/', methods=['GET'])
29
+ def health_check():
30
+ return jsonify({"status": "SWARM_NODE_ONLINE"})
 
 
 
 
31
 
32
+ if __name__ == "__main__":
33
+ app.run(host="0.0.0.0", port=7860)