artydev commited on
Commit
ffd8348
·
verified ·
1 Parent(s): b410e7e

deploy at 2024-08-31 00:00:57.630975

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fasthtml.common import *
2
+ from fasthtml_hf import setup_hf_backup
3
+ app,rt = fast_app(hdrs=[HighlightJS()])
4
+
5
+ @rt("/convert")
6
+ def post(html:str, attr1st:bool): return Pre(Code(html2ft(html, attr1st=str2bool(attr1st)))) if html else ''
7
+
8
+ @rt("/")
9
+ def get():
10
+ return Titled(
11
+ "Convert HTML to FT",
12
+ Form(hx_post='/convert', target_id="ft", hx_trigger="change from:#attr1st, keyup delay:500ms from:#html")(
13
+ Select(style="width: auto", id="attr1st")(
14
+ Option("Children 1st", value="0", selected=True), Option("Attrs 1st", value="1")),
15
+ Textarea(placeholder='Paste HTML here', id="html", rows=10)),
16
+ Div(id="ft"))
17
+
18
+
19
+
20
+ setup_hf_backup(app)
21
+ serve()