Spaces:
Sleeping
Sleeping
Upload qubit_medic/server/app.py with huggingface_hub
Browse files- qubit_medic/server/app.py +43 -0
qubit_medic/server/app.py
CHANGED
|
@@ -24,6 +24,7 @@ import sys
|
|
| 24 |
from typing import Optional
|
| 25 |
|
| 26 |
from fastapi import Body, HTTPException
|
|
|
|
| 27 |
from openenv.core import create_fastapi_app
|
| 28 |
|
| 29 |
from qubit_medic.config import DEFAULT_HOST, DEFAULT_PORT
|
|
@@ -185,6 +186,48 @@ def decode(
|
|
| 185 |
}
|
| 186 |
|
| 187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
# --------------------------------------------------------------------------- #
|
| 189 |
# Local entry point #
|
| 190 |
# --------------------------------------------------------------------------- #
|
|
|
|
| 24 |
from typing import Optional
|
| 25 |
|
| 26 |
from fastapi import Body, HTTPException
|
| 27 |
+
from fastapi.responses import HTMLResponse
|
| 28 |
from openenv.core import create_fastapi_app
|
| 29 |
|
| 30 |
from qubit_medic.config import DEFAULT_HOST, DEFAULT_PORT
|
|
|
|
| 186 |
}
|
| 187 |
|
| 188 |
|
| 189 |
+
# --------------------------------------------------------------------------- #
|
| 190 |
+
# Root landing page #
|
| 191 |
+
# --------------------------------------------------------------------------- #
|
| 192 |
+
|
| 193 |
+
@app.get("/", response_class=HTMLResponse, include_in_schema=False)
|
| 194 |
+
def root() -> HTMLResponse:
|
| 195 |
+
"""HTML landing page shown in the HF Spaces App tab."""
|
| 196 |
+
html = """<!DOCTYPE html>
|
| 197 |
+
<html lang="en">
|
| 198 |
+
<head>
|
| 199 |
+
<meta charset="UTF-8">
|
| 200 |
+
<title>Qubit-Medic — OpenEnv server</title>
|
| 201 |
+
<style>
|
| 202 |
+
body { font-family: sans-serif; max-width: 680px; margin: 60px auto; color: #e0e0e0; background: #0d1117; }
|
| 203 |
+
h1 { font-size: 1.5rem; }
|
| 204 |
+
a { color: #58a6ff; }
|
| 205 |
+
code { background: #161b22; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
|
| 206 |
+
ul { line-height: 2; }
|
| 207 |
+
</style>
|
| 208 |
+
</head>
|
| 209 |
+
<body>
|
| 210 |
+
<h1>Qubit-Medic — OpenEnv server</h1>
|
| 211 |
+
<p>
|
| 212 |
+
This Space exposes a <strong>JSON API</strong> for the quantum
|
| 213 |
+
error-decoding environment (Stim + PyMatching, OpenEnv contract).
|
| 214 |
+
Use the links below to interact with it.
|
| 215 |
+
</p>
|
| 216 |
+
<ul>
|
| 217 |
+
<li><a href="/docs">Interactive API docs (Swagger)</a></li>
|
| 218 |
+
<li><a href="/redoc">ReDoc</a></li>
|
| 219 |
+
<li><a href="/healthz">Liveness <code>GET /healthz</code></a> — versions probe</li>
|
| 220 |
+
<li><a href="/metadata">OpenEnv <code>GET /metadata</code></a></li>
|
| 221 |
+
</ul>
|
| 222 |
+
<p>
|
| 223 |
+
Typical flow: <code>POST /reset</code> then <code>POST /step</code>
|
| 224 |
+
with the model’s text action — see the schema in <a href="/docs">/docs</a>.
|
| 225 |
+
</p>
|
| 226 |
+
</body>
|
| 227 |
+
</html>"""
|
| 228 |
+
return HTMLResponse(content=html)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
# --------------------------------------------------------------------------- #
|
| 232 |
# Local entry point #
|
| 233 |
# --------------------------------------------------------------------------- #
|