fix: drhider standalone server port 8767, inline SVG, DB try/except
Deploy contracts-flask / validate (push) Successful in 0s
Deploy contracts-flask / validate (push) Successful in 0s
This commit is contained in:
+35
-18
@@ -18,25 +18,41 @@ if os.path.exists(_env_path):
|
||||
os.environ[_k] = _v
|
||||
|
||||
# ── DB auto-seed ──────────────────────────────────────────────────────────
|
||||
from db import prompts as db_prompts
|
||||
from db.connection import DB_CONFIG, execute
|
||||
db_prompts.seed_defaults()
|
||||
# Schema migration: classify_raw column (idempotent)
|
||||
execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS classify_raw text")
|
||||
execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS classify_input text")
|
||||
execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS zip_source text")
|
||||
execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS content_hash text")
|
||||
try:
|
||||
from db import prompts as db_prompts
|
||||
from db.connection import DB_CONFIG, execute
|
||||
db_prompts.seed_defaults()
|
||||
# Schema migration: classify_raw column (idempotent)
|
||||
execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS classify_raw text")
|
||||
execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS classify_input text")
|
||||
execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS zip_source text")
|
||||
execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS content_hash text")
|
||||
|
||||
# ── DB modules ────────────────────────────────────────────────────────────
|
||||
from db import supplements as db_supplements
|
||||
from db import documents as db_documents
|
||||
from db import spec_current as db_spec_current
|
||||
# ── DB modules ────────────────────────────────────────────────────────────
|
||||
from db import supplements as db_supplements
|
||||
from db import documents as db_documents
|
||||
from db import spec_current as db_spec_current
|
||||
DB_OK = True
|
||||
except Exception as _db_err:
|
||||
import sys as _sys
|
||||
print(f"WARNING: DB init failed ({_db_err}), running without DB", file=_sys.stderr)
|
||||
DB_CONFIG = {"dbname": "NONE"}
|
||||
DB_OK = False
|
||||
# Stubs for DB-dependent handlers
|
||||
db_prompts = None
|
||||
db_supplements = None
|
||||
db_documents = None
|
||||
db_spec_current = None
|
||||
|
||||
# ── Services ──────────────────────────────────────────────────────────────
|
||||
from services.upload import handle_upload
|
||||
from services.unzip import handle_unzip
|
||||
from services.process import run_pipeline
|
||||
from llm_prompt import build_prompt
|
||||
if DB_OK:
|
||||
from services.upload import handle_upload
|
||||
from services.unzip import handle_unzip
|
||||
from services.process import run_pipeline
|
||||
from llm_prompt import build_prompt
|
||||
else:
|
||||
handle_upload = handle_unzip = run_pipeline = None
|
||||
build_prompt = None
|
||||
|
||||
|
||||
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
|
||||
@@ -56,7 +72,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if parsed.path == "/process-v2":
|
||||
self._handle_process_v2(parsed)
|
||||
elif parsed.path == "/health":
|
||||
self._json({"ok": True, "db": DB_CONFIG["dbname"]})
|
||||
self._json({"ok": True, "db": DB_CONFIG.get("dbname", "NONE")})
|
||||
elif parsed.path == "/app.js" or parsed.path.startswith("/static/"):
|
||||
self._handle_app_js()
|
||||
elif parsed.path == "/api/supplements":
|
||||
@@ -590,7 +606,8 @@ if __name__ == "__main__":
|
||||
TCPServer.allow_reuse_address = True
|
||||
port = int(os.environ.get("PORT", "8766"))
|
||||
server = ThreadingHTTPServer(("0.0.0.0", port), Handler)
|
||||
print(f"Contracts VM server on :{port}, db={DB_CONFIG['dbname']}")
|
||||
db_name = DB_CONFIG.get("dbname", "NONE") if DB_CONFIG else "NONE"
|
||||
print(f"Contracts VM server on :{port}, db={db_name}")
|
||||
try:
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Reference in New Issue
Block a user