70 lines
1.7 KiB
Python
70 lines
1.7 KiB
Python
from fasthtml.common import *
|
|
import os
|
|
|
|
|
|
app= FastHTML()
|
|
def listUsers():
|
|
with os.scandir("static") as files:
|
|
subdir = [file.name for file in files if file.is_dir()]
|
|
return subdir
|
|
|
|
def menuusers(users):
|
|
T=[]
|
|
n=0
|
|
for user in users:
|
|
T.append(Option(user, value=str(user)) )
|
|
return Form(
|
|
Select(*T,
|
|
cls="selector",
|
|
_id="counter",
|
|
name="data",
|
|
**{'@click':"alert('Clicked');"},),Button("Submit"),action="/checkInfoSources", method="post")
|
|
|
|
@app.post("/checkInfoSources")
|
|
def checkInfoSources(data:str):
|
|
print(data)
|
|
with os.scandir("static/"+data) as files:
|
|
subdir = [CheckboxX(label=file.name,value="static/"+data+"/"+file.name) for file in files if file.is_file()]
|
|
return Form(
|
|
Label(*subdir,
|
|
cls="selector",
|
|
_id="counter",
|
|
hx_target="files",
|
|
name="data",
|
|
**{'@click':"alert('Clicked');"},),Button("Submit"),action="/process", method="post")
|
|
|
|
|
|
@app.post("/process")
|
|
def processData():
|
|
print()
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/")
|
|
def home():
|
|
page = Html(
|
|
Head(Title('Super tutor')),
|
|
Body(Div('Este es el sistema de super tutor, ',
|
|
menuusers(listUsers()),
|
|
A('A link', href='https://example.com'),
|
|
Img(src="https://placehold.co/200"),
|
|
Form(
|
|
Select(
|
|
Option("user", value=str("user"))),
|
|
Button("Submit"),
|
|
action="/", method="post"), cls='myclass')),
|
|
Div(id="files"))
|
|
|
|
|
|
|
|
return page
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
|
|
|
|
|
|
|
|
serve() |