DJ-Goanna-Coding commited on
Commit
daf2633
·
verified ·
1 Parent(s): 925b7ae

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +37 -56
app.py CHANGED
@@ -1,58 +1,39 @@
1
- import gradio as gr
2
- import json
3
 
4
- def safe_import(module_path, attr=None):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  try:
6
- module = __import__(module_path, fromlist=[attr] if attr else [])
7
- return getattr(module, attr) if attr else module
8
- except Exception:
9
- return None
10
-
11
- TIAWorker = safe_import("TIA.worker", "TIAWorker")
12
- PrimeSchema = safe_import("citadel.primeSchema", "PrimeSchema")
13
- HoloCommandCentre = safe_import("citadel.holo3d.ui.commandCentre", "CommandCentre")
14
-
15
- def qgtnl_process(command):
16
- result = {
17
- "command": command,
18
- "tia": None,
19
- "lineage": None,
20
- "status": "OK"
21
- }
22
-
23
- if TIAWorker:
24
- try:
25
- result["tia"] = TIAWorker().process(command)
26
- except Exception as e:
27
- result["tia"] = f"TIA error: {e}"
28
-
29
- if PrimeSchema:
30
- try:
31
- result["lineage"] = PrimeSchema().summarize()
32
- except Exception as e:
33
- result["lineage"] = f"Lineage error: {e}"
34
-
35
- return json.dumps(result, indent=2)
36
-
37
- with gr.Blocks(css="body { background: black; color: cyan; }") as app:
38
- gr.Markdown("# **QGTNL Command Centre**")
39
- gr.Markdown("### Citadel • TIA • AION • ORACLE • Holo3D")
40
-
41
- with gr.Row():
42
- cmd = gr.Textbox(label="Command Input")
43
- out = gr.Code(label="System Output")
44
-
45
- run = gr.Button("Execute")
46
- run.click(qgtnl_process, cmd, out)
47
-
48
- gr.Markdown("---")
49
- gr.Markdown("### Holo3D UI (if available)")
50
-
51
- if HoloCommandCentre:
52
- try:
53
- html = HoloCommandCentre().render()
54
- gr.HTML(html)
55
- except:
56
- gr.Markdown("Holo3D failed to load.")
57
-
58
- app.launch()
 
 
 
1
 
2
+ import os, json
3
+ from flask import Flask, request, jsonify
4
+ from huggingface_hub import HfApi
5
+
6
+ app = Flask(__name__)
7
+ # Securely pulling the token from the Space's settings
8
+ TOKEN = os.getenv("HF_TOKEN")
9
+ VAULT_ID = "DJ-Goanna-Coding/TIA-storage"
10
+ api = HfApi(token=TOKEN)
11
+
12
+ @app.route('/ignite_harvest', methods=['POST'])
13
+ @app.route('/ingest', methods=['POST'])
14
+ def catch_payload():
15
+ if not TOKEN:
16
+ return jsonify({"status": "ERROR", "message": "HF_TOKEN secret is missing in Space settings"}), 500
17
+
18
  try:
19
+ payload = request.json
20
+ filename = payload.get("fileName", "unknown_shard.9293")
21
+ content = payload.get("content", "")
22
+
23
+ # Save the incoming lightweight text directly to the HF Dataset
24
+ api.upload_file(
25
+ path_or_fileobj=content.encode('utf-8'),
26
+ path_in_repo=f"ingested_core/{filename}",
27
+ repo_id=VAULT_ID,
28
+ repo_type="dataset"
29
+ )
30
+ return jsonify({"status": "CAUGHT_AND_STORED", "file": filename}), 200
31
+ except Exception as e:
32
+ return jsonify({"status": "ERROR", "message": str(e)}), 500
33
+
34
+ @app.route('/', methods=['GET'])
35
+ def health_check():
36
+ return jsonify({"status": "SOVEREIGN_NODE_ONLINE", "vault": "TIA-storage"})
37
+
38
+ if __name__ == "__main__":
39
+ app.run(host="0.0.0.0", port=7860)