-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheqsheet_web.py
More file actions
38 lines (27 loc) · 1.17 KB
/
Copy patheqsheet_web.py
File metadata and controls
38 lines (27 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
The Flask half of the Numerical Solver: the Blueprint the main app
mounts at /eqsheet/, and nothing else.
It exists because eqsheet.py does not import Flask any more (#208,
31 Aug 2026). The Solver now runs in the offline builds too, where
Pyodide imports that module inside the browser tab and there is no
server to speak HTTP to, so the parsing and the solving had to stop
being route handlers. What was a Blueprint decorator is three lines of
wrapping here; repos/local/bridge.py wraps the same two functions the
other way, in JSON.
Keep this file thin. Anything with an opinion about the mathematics
belongs in eqsheet.py, where both front ends can reach it -- a check
added here alone would guard the hosted Solver and leave the
downloaded one without it.
"""
from flask import Blueprint, request, jsonify, render_template
import eqsheet
bp = Blueprint("eqsheet", __name__, url_prefix="/eqsheet")
@bp.post("/api/parse")
def api_parse():
return jsonify(eqsheet.api_parse(request.get_json(force=True)))
@bp.post("/api/solve")
def api_solve():
return jsonify(eqsheet.api_solve(request.get_json(force=True)))
@bp.get("/")
def index():
return render_template("eqsheet.html")