Download app.py from Percy3822/Python_ai: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/Percy3822/Python_ai/resolve/ca39b28fa699dbd9c2ae37c0f90be0160b56f824/app.py
- Command line
-
hf download hf://spaces/Percy3822/Python_ai@ca39b28fa699dbd9c2ae37c0f90be0160b56f824/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Percy3822/Python_ai/resolve/ca39b28fa699dbd9c2ae37c0f90be0160b56f824/app.py
1.04 kB
| from fastapi import FastAPI, Body | |
| app = FastAPI(title="Python_ai") | |
| def health(): | |
| return {"ok": True} | |
| def code_help(payload: dict = Body(...)): | |
| # Trivial fixer: rename "reslt" -> "result" if present | |
| viewport = payload.get("telemetry", {}).get("viewport", {}) | |
| text = viewport.get("text", "") | |
| if "reslt" in text and "result" not in text: | |
| patch = text.replace("reslt", "result") | |
| return { | |
| "mode": "patch", | |
| "patch": f"--- a/main.py\n+++ b/main.py\n@@ -1 +1 @@\n-{text}\n\n+{patch}\n\n", | |
| "full_text": "", | |
| "explanation": "Fixed misspelling 'reslt' -> 'result'.", | |
| "confidence": 0.95, | |
| "need": {"function": False, "xrefs": [], "page_ids": []}, | |
| } | |
| # Default no-op | |
| return { | |
| "mode": "patch", | |
| "patch": "", | |
| "full_text": "", | |
| "explanation": "No obvious fix.", | |
| "confidence": 0.5, | |
| "need": {"function": False, "xrefs": [], "page_ids": []}, | |
| } |