-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (35 loc) · 1.16 KB
/
main.py
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
39
40
from flask import Flask, request, jsonify, render_template
from app.debugger import Debugger
# Initialize Flask app and Debugger instance
app = Flask(__name__)
debugger = Debugger()
@app.route("/")
def index():
return render_template("index.html")
@app.route("/load_snapshot", methods=["POST"])
def load_snapshot():
snapshot_index = request.json.get("index")
print(f"Requested snapshot index: {snapshot_index}") # Debugging print
try:
snapshot = debugger.load_snapshot(snapshot_index)
print(f"Loaded snapshot: {snapshot}") # Debugging print
response = {
"status": "success",
"snapshot": {
"filename": snapshot["filename"],
"line_number": snapshot["line_number"],
"local_variables": snapshot["local_variables"],
}
}
except IndexError:
response = {"status": "error", "message": "Snapshot not found."}
print("Snapshot not found!")
return jsonify(response)
def test_function():
a = 1
b = 2
c = a + b +b
return c
if __name__ == "__main__":
debugger.start_debugging(test_function)
app.run(debug=True)