Spaces:
Sleeping
Sleeping
deploy at 2024-08-12 17:49:54.288324
Browse files
main.py
CHANGED
@@ -17,6 +17,7 @@ def pyconsole():
|
|
17 |
Input(name="code", placeholder=">>> Type Python code here (and hit enter)"),
|
18 |
hx_post="/run", hx_target="#output", hx_trigger="submit", id="input_form",
|
19 |
),
|
|
|
20 |
cls="container",
|
21 |
hx_swap="innerHTML show:window:bottom", # automatically scroll to the bottom of the page
|
22 |
)
|
@@ -28,5 +29,11 @@ def run_code(data: dict):
|
|
28 |
return Div(*[Div(Pre(Code(code, klass="python")), Div(output, cls="marked"), Div("---", cls="marked")) for code, output in log])
|
29 |
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
setup_hf_backup(app)
|
32 |
serve()
|
|
|
17 |
Input(name="code", placeholder=">>> Type Python code here (and hit enter)"),
|
18 |
hx_post="/run", hx_target="#output", hx_trigger="submit", id="input_form",
|
19 |
),
|
20 |
+
Div("Clear log", hx_get="/clear", hx_target="#output", style="background-color: #f0f0f0; border-radius: 10px; padding: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);"),
|
21 |
cls="container",
|
22 |
hx_swap="innerHTML show:window:bottom", # automatically scroll to the bottom of the page
|
23 |
)
|
|
|
29 |
return Div(*[Div(Pre(Code(code, klass="python")), Div(output, cls="marked"), Div("---", cls="marked")) for code, output in log])
|
30 |
|
31 |
|
32 |
+
@app.get("/clear")
|
33 |
+
def clear_log():
|
34 |
+
global log
|
35 |
+
log = []
|
36 |
+
return Div()
|
37 |
+
|
38 |
setup_hf_backup(app)
|
39 |
serve()
|