-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
682 lines (615 loc) · 27.4 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
from fasthtml.common import *
from tinydb import TinyDB, Query
from urllib.parse import parse_qs
import secrets, json
# Initialize FastHTML app and TinyDB database
app = FastHTML(exts='ws')
rt = app.route
db = TinyDB("flarebase_storage.json")
db_query = Query()
# Import REST routes
from routes import REST
# ------------------------------
# Helper Functions
# ------------------------------
def list_tables():
"""Generate a list of tables as clickable cards."""
database = db.tables()
cards = []
for key in database:
cards.append(
Button(
Div(key, cls="text-lg font-bold"),
Div("Table", cls="text-md"),
cls="card text-left bg-base-300 w-48 mb-3 hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-4 m-2",
style="border-radius: 0;",
hx_post=f"/view_table/{key}",
hx_target="#records",
hx_swap="innerHTML"
)
)
return Div(*cards, cls="overflow-x-auto")
def keys_list(table):
"""Extract unique keys (columns) from a table."""
all_keys = set()
for doc in db.table(table).all():
all_keys.update(doc.keys())
return list(all_keys)
def list_records(table_input):
"""Display all records in a given table."""
headers = keys_list(table_input)
table = db.table(table_input)
records = table.all()
if not records:
# Handle case where no records exist
return Div(
H3(f"Table {table_input}", cls="text-lg font-bold mb-4"),
Div("No records available.", cls="text-gray-500"),
cls="p-4"
)
# Add "Actions" column to headers
headers.append("Actions")
# Table headers
table_head = Tr(
*[Th(header, cls="text-left px-4 py-2 font-bold") for header in headers],
cls="bg-base-300 border-2 border-black"
)
# Table rows with actions
table_body = []
for record in records:
# Skip record if all its values are None or empty
if all(value in (None, "") for value in record.values()):
continue
# Add data cells for each column
row_data = [
Td(record.get(header, ""), cls="px-4 py-2")
for header in headers[:-1] # Exclude the "Actions" column
]
# Add action buttons
actions = Td(
Div(
Label(
I(cls="ti ti-edit text-xl"),
cls="btn btn-sm btn-ghost btn-square hover:bg-warning",
hx_post=f"/fetch_fields/{table_input}/update/{record.doc_id}",
hx_target="#record-form-fields",
**{"for": "add-record-drawer"}
),
Button(
I(cls="ti ti-trash text-xl text-red-600"),
cls="btn btn-sm btn-ghost btn-square hover:bg-warning",
hx_post=f"/delete_record/{table_input}/{record.doc_id}",
hx_target="#records",
hx_confirm="Are you sure you want to delete this record?"
),
cls="flex gap-1"
),
cls="px-4 py-2"
)
row_data.append(actions)
# Append the row to the table body
table_body.append(
Tr(*row_data, cls="bg-base-300 hover:bg-warning hover:text-black")
)
# If no valid rows remain, show a message instead of an empty table
if not table_body:
return Div(
H3(f"Table '{table_input}'", cls="text-lg font-bold mb-4"),
Div("No valid records to display.", cls="text-gray-500"),
cls="p-4"
)
# Return the table
return Table(
Thead(table_head),
Tbody(*table_body),
cls="table-auto border-2 border-black w-full bg-base-300 shadow-[8px_8px_0px_rgba(0,0,0,1)]",
)
# ------------------------------
# Routes
# ------------------------------
@rt('/')
def get():
# Drawer for adding a new table
add_collection = Div(
Div(
Input(id="add-key-drawer", type="checkbox", cls="drawer-toggle"),
Div(cls="drawer-content"),
Div(
Label(cls="drawer-overlay", **{"for": "add-key-drawer"}),
Div(
H3("Add New Table", cls="text-xl font-bold flex justify-center"),
Form(
Div(
Div(
Label("Table Name:", cls="text-lg font-bold label"),
Input(
type="text",
name="table-name",
placeholder="Table",
cls="grow w-full border-black border-2 p-2.5 focus:outline-none focus:shadow-[2px_2px_0px_rgba(0,0,0,1)] focus:bg-base-300 active:shadow-[2px_2px_0px_rgba(0,0,0,1)] rounded-md text-lg font-bold"
),
cls="mb-4"
),
Div(
Label("Fields:", cls="text-lg font-bold label"),
Div(
Label(Input(type="text",name="field",cls="grow border-black border-2 p-2.5 focus:outline-none focus:shadow-[2px_2px_0px_rgba(0,0,0,1)] focus:bg-base-300 active:shadow-[2px_2px_0px_rgba(0,0,0,1)] rounded-md text-lg font-bold",placeholder="Field"),
cls=" flex items-center mb-2",id="fields-inputs"),
id='fields',
cls="h-32 overflow-y-auto"
),
Label(
"Add field",
type="button",
hx_post="/add_field",
hx_target="#fields",
hx_swap="beforeend",
cls="card bg-base-300 w-32 hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-4 font-bold text-center mt-3 text-lg font-bold",
style="border-radius: 0;"
),
cls="mb-4"
),
Div(
Label(
"Add table",
type="button",
hx_post="/create_table",
hx_include="#fields-inputs input",
cls="card rounded-none bg-base-300 w-full hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-4 font-bold text-center text-lg font-bold",
style="border-radius: 0;"
),
cls="mt-12"
),
cls="p-4"
),
cls="bg-ghost rounded-lg"
),
cls="menu text-base-content min-h-full w-96 p-4 bg-base-200"
),
cls="drawer-side"
),
cls="drawer drawer-end"
)
)
# Updated Drawer for adding a new record with dynamic fields
add_record = Div(
Div(
Input(id="add-record-drawer", type="checkbox", cls="drawer-toggle"),
Div(cls="drawer-content"),
Div(
Label(cls="drawer-overlay", **{"for": "add-record-drawer"}),
Div(
H3("Add New Record",id="record-form-fields",cls="text-lg font-bold mb-4"),
cls="menu bg-base-200 text-base-content min-h-full w-80 p-4"
),
cls="drawer-side"
),
cls="drawer drawer-end"
)
)
# Table list as cards
tables = Div(
Div(
Div("Tables", cls="text-lg text-warning font-bold w-48"),
list_tables(),
cls="flex flex-col gap-3"
),
cls="overflow-y-auto p-4"
)
# Records section
records = Div(
Table(cls="table-auto w-full bg-ghost", id="records"),
cls="bg-ghost flex-grow"
)
return Div(
Header(
Link(
rel="stylesheet",
href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/dist/tabler-icons.min.css"
),
Link(
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.min.css",
rel="stylesheet",
type="text/css"
),
Script(src="https://cdn.tailwindcss.com")
),
Head(
Div(
Div(I(cls="ti ti-comet text-4xl -translate-y-1"), " Flarebase", cls="text-xl text-warning font-bold navbar-start"),
Div(A(I(cls="ti ti-brand-github text-3xl"), href="https://github.com/Anas099X/Flarebase/blob/main/docs/Flarebase_Documentation.md"),
cls="text-warning m-2 font-bold navbar-end"),
cls="navbar bg-ghost"
)
),
Body(
Div(
Div(
Div(
Div(
Div(I(cls="ti ti-database text-warning text-2xl"), " Database", cls="text-2xl text-warning font-bold"),
Div(
A(cls="ti ti-database mr-2"),
A(cls="ti ti-lock-square-rounded mr-2"),
A(cls="ti ti-photo text-warning text-3xl mr-2"),
cls="text-3xl text-warning font-bold flex"
),
cls="flex justify-between w-full"
),
Div(
tables,
Div(cls="divider divider-horizontal"),
records,
cls="flex w-full max-w-6xl h-80"
),
Label(
"Add table",
cls="card bg-base-300 w-32 hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-4 font-bold text-center",
style="border-radius: 0;",
**{"for": "add-key-drawer"}
),
cls="card-body"
),
cls="card shadow-xl mx-auto w-full max-w-6xl bg-base-200"
),
add_collection,
add_record,
cls="container mx-auto py-6 px-4"
),
data_theme="dim",
style="min-height: 100vh;"
),
cls="bg-base-100",
)
@rt("/logo")
def get():
return Div(
Header(
Link(
rel="stylesheet",
href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/dist/tabler-icons.min.css"
),
Link(
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.min.css",
rel="stylesheet",
type="text/css"
),
Script(src="https://cdn.tailwindcss.com")
),
Div(
Div(
Div(I(cls="ti ti-comet text-warning text-8xl"), "Flarebase", cls="text-6xl text-warning font-bold"),
cls="max-w-md"
),
cls="hero-content text-center"
),
data_theme="dim",
cls="hero bg-base-100 min-h-screen"
)
@rt("/view_table/{selected_table}")
def post(selected_table: str):
if not selected_table:
return Div("No table selected.", cls="text-red-600")
if selected_table not in db.tables():
return Div(f"Table '{selected_table}' does not exist.", cls="text-red-600")
# Return both the records and update the "Add record" and "Delete table" buttons
return Div(
# Display the GET API URL for the table
Div(
Div("GET", cls="badge badge-warning mr-1"),
f"/api/tables/{selected_table}",
cls="bg-base-300 w-full h-10 border-2 border-black shadow-md shadow-[3px_5px_0px_rgba(0,0,0,1)] p-1 font-bold text-center text-primary mb-3"
),
# List records from the selected table
Div(list_records(selected_table),cls="w-full h-64 bg-ghost flex-grow overflow-y-auto overflow-x-auto"),
# Add record and delete table buttons
Div(
# Add record button
Label(
"Add record",
cls="card bg-base-300 w-64 hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-4 font-bold text-center mt-5",
style="border-radius: 0;",
hx_post=f"/fetch_fields/{selected_table}/add",
hx_target="#record-form-fields",
**{"for": "add-record-drawer"}
),
# Delete table button
Label(
Div(cls="ti ti-trash text-xl text-red-600 text-center"),
cls="card bg-base-300 w-12 h-12 hover:bg-warning hover:text-black border-2 border-black translate-x-1 translate-y-1.5 hover:translate-x-2 hover:translate-y-2 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-3 font-bold text-center mt-5 ml-1",
style="border-radius: 0;",
hx_confirm="Are you sure you want to delete this table?",
hx_delete=f"/api/tables/{selected_table}"
),
cls="flex justify-center"
)
)
@rt("/delete_table/{table}")
def post(table:str):
db.drop_table(table)
return Redirect("/")
@rt("/create_table")
async def post(request: Request):
form = await request.form()
table_name = form.get("table-name")
if not table_name:
return Div("Table name cannot be empty.", cls="text-red-600")
if table_name in db.tables():
return Div("Table already exists.", cls="text-red-600")
table = db.table(table_name)
for key, value in form.items():
if key != "table-name":
if not value:
return Div("Fields cannot be empty.", cls="text-red-600")
else:
table.insert({value: ""})
return Redirect("/")
@rt("/fetch_fields/{table_name}/{mode}/{record_id}")
def post(table_name: str ,mode:str ,record_id:int = None):
"""Fetch and display fields for the selected table"""
if table_name == "default" or table_name not in db.tables():
return Div("Please select a table first", cls="text-red-600")
fields = keys_list(table_name)
table = db.table(table_name)
records = table.get(doc_id=record_id)
if 'add' in mode:
return Form(
H3(f"Add record to {table_name}", cls="text-lg font-bold mb-4"),
*[
Div(
Label(field.title() + ":", cls="label"),
Input(
type="text",
name=field,
placeholder=f"Enter {field.lower()}",
cls="grow w-full border-black border-2 p-2.5 focus:outline-none focus:shadow-[2px_2px_0px_rgba(0,0,0,1)] focus:bg-base-300 active:shadow-[2px_2px_0px_rgba(0,0,0,1)] rounded-md"
),
cls="mb-4"
)
for field in fields if field # Skip empty fields
],
Label(
"Add Record",
type="submit",
hx_post=f"/add_record/{table_name}",
hx_target="#records",
style="border-radius: 0;",
cls="card bg-base-300 w-full hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-3 font-bold text-center mt-2"
),
cls="p-4 bg-ghost rounded-lg"
)
elif 'update' in mode:
return Form(
H3(f"Update record of {table_name}", cls="text-lg font-bold mb-4"),
*[
Div(
Label(key + ":", cls="label"),
Input(
type="text",
name=key,
value=record,
placeholder=f"Enter {key.lower()}",
cls="grow w-full border-black border-2 p-2.5 focus:outline-none focus:shadow-[2px_2px_0px_rgba(0,0,0,1)] focus:bg-base-300 active:shadow-[2px_2px_0px_rgba(0,0,0,1)] rounded-md"
),
cls="mb-4"
) # Skip empty fields
for key ,record in records.items()
][::-1],
Label(
"Update Record",
type="submit",
hx_post=f"/update_record/{table_name}/{record_id}",
hx_target="#records",
cls="card bg-base-300 w-full hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-3 font-bold text-center mt-2"
),
cls="p-4 bg-ghost rounded-lg"
)
@rt("/add_record/{table_name}")
async def post(request: Request, table_name: str):
"""Add a record to the specified table with dynamic fields"""
if table_name not in db.tables():
return Div("Table not found", cls="text-red-600")
form = await request.form()
# Create record dictionary from form data
record = {key: value for key, value in form.items() if value.strip()}
if not record:
return Div("Please fill at least one field", cls="text-red-600 text-lg"),Div(
Label(
"Add record",
cls="btn bg-black btn-outline w-64 mt-5 flex self-center",
style="border-radius: 0;",
hx_post=f"/fetch_fields/{table_name}/add",
hx_target="#record-form-fields",
**{"for": "add-record-drawer"}
),
cls="flex justify-center"
)
# Insert the record
db.table(table_name).insert(record)
# Return updated table view
return Div(
# Display the GET API URL for the table
Div(
Div("GET", cls="badge badge-warning mr-1"),
f"/api/tables/{table_name}",
cls="bg-base-300 w-full h-10 border-2 border-black shadow-md shadow-[3px_5px_0px_rgba(0,0,0,1)] p-1 font-bold text-center text-primary mb-3"
),
# List records from the selected table
Div(list_records(table_name),cls="w-full h-64 bg-ghost flex-grow overflow-y-auto overflow-x-auto"),
# Add record and delete table buttons
Div(
# Add record button
Label(
"Add record",
cls="card bg-base-300 w-64 hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-4 font-bold text-center mt-5",
style="border-radius: 0;",
hx_post=f"/fetch_fields/{table_name}/add",
hx_target="#record-form-fields",
**{"for": "add-record-drawer"}
),
# Delete table button
Label(
Div(cls="ti ti-trash text-xl text-red-600 text-center"),
cls="card bg-base-300 w-12 h-12 hover:bg-warning hover:text-black border-2 border-black translate-x-1 translate-y-1.5 hover:translate-x-2 hover:translate-y-2 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-3 font-bold text-center mt-5 ml-1",
style="border-radius: 0;",
hx_confirm="Are you sure you want to delete this table?",
hx_delete=f"/api/tables/{table_name}"
),
cls="flex justify-center"
)
)
@rt("/update_record/{table_name}/{record_id}")
async def post(request: Request, table_name: str, record_id: int):
"""Add a record to the specified table with dynamic fields"""
if table_name not in db.tables():
return Div("Table not found", cls="text-red-600")
form = await request.form()
# Create record dictionary from form data
record = {key: value for key, value in form.items() if value.strip()}
# Update the record
table = db.table(table_name)
table.update(record, doc_ids=[record_id])
# Return updated table view
return Div(
# Display the GET API URL for the table
Div(
Div("GET", cls="badge badge-warning mr-1"),
f"/api/tables/{table_name}",
cls="bg-base-300 w-full h-10 border-2 border-black shadow-md shadow-[3px_5px_0px_rgba(0,0,0,1)] p-1 font-bold text-center text-primary mb-3"
),
# List records from the selected table
Div(list_records(table_name),cls="w-full h-64 bg-ghost flex-grow overflow-y-auto overflow-x-auto"),
# Add record and delete table buttons
Div(
# Add record button
Label(
"Add record",
cls="card bg-base-300 w-64 hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-4 font-bold text-center mt-5",
style="border-radius: 0;",
hx_post=f"/fetch_fields/{table_name}/add",
hx_target="#record-form-fields",
**{"for": "add-record-drawer"}
),
# Delete table button
Label(
Div(cls="ti ti-trash text-xl text-red-600 text-center"),
cls="card bg-base-300 w-12 h-12 hover:bg-warning hover:text-black border-2 border-black translate-x-1 translate-y-1.5 hover:translate-x-2 hover:translate-y-2 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-3 font-bold text-center mt-5 ml-1",
style="border-radius: 0;",
hx_confirm="Are you sure you want to delete this table?",
hx_delete=f"/api/tables/{table_name}"
),
cls="flex justify-center"
)
)
@rt("/delete_record/{table_name}/{record_id}")
def post(table_name: str, record_id: int):
"""Delete a specific record from a table"""
table = db.table(table_name)
table.remove(doc_ids=[record_id])
return Div(
# Display the GET API URL for the table
Div(
Div("GET", cls="badge badge-warning mr-1"),
f"/api/tables/{table_name}",
cls="bg-base-300 w-full h-10 border-2 border-black shadow-md shadow-[3px_5px_0px_rgba(0,0,0,1)] p-1 font-bold text-center text-primary mb-3"
),
# List records from the selected table
Div(list_records(table_name),cls="w-full h-64 bg-ghost flex-grow overflow-y-auto overflow-x-auto"),
# Add record and delete table buttons
Div(
# Add record button
Label(
"Add record",
cls="card bg-base-300 w-64 hover:bg-warning hover:text-black border-2 border-black hover:translate-x-1 hover:translate-y-1 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-4 font-bold text-center mt-5",
style="border-radius: 0;",
hx_post=f"/fetch_fields/{table_name}/add",
hx_target="#record-form-fields",
**{"for": "add-record-drawer"}
),
# Delete table button
Label(
Div(cls="ti ti-trash text-xl text-red-600 text-center"),
cls="card bg-base-300 w-12 h-12 hover:bg-warning hover:text-black border-2 border-black translate-x-1 translate-y-1.5 hover:translate-x-2 hover:translate-y-2 shadow-md hover:shadow-[3px_5px_0px_rgba(0,0,0,1)] p-3 font-bold text-center mt-5 ml-1",
style="border-radius: 0;",
hx_confirm="Are you sure you want to delete this table?",
hx_delete=f"/api/tables/{table_name}"
),
cls="flex justify-center"
)
)
@rt("/add_field")
def post():
return Label(
Input(type="text", name=f"field {secrets.token_urlsafe(5)}", cls="grow w-full border-black border-2 p-2.5 focus:outline-none focus:shadow-[2px_2px_0px_rgba(0,0,0,1)] focus:bg-base-300 active:shadow-[2px_2px_0px_rgba(0,0,0,1)] rounded-md text-lg font-bold",placeholder="Field"),
Button(
hx_post="/remove_field",
hx_target="#field-label",
hx_swap="delete",
cls="ti ti-trash text-2xl text-red-600 m-1"
),
cls="flex items-center mb-2",
id="field-label"
)
@rt("/remove_field")
def post():
return Div()
@rt('/landing')
def get():
return Div(
Head(
Title("Flarebase - Landing Page"),
Link(rel="stylesheet", href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.min.css"),
Link(rel="stylesheet", href="https://cdn.jsdelivr.net/npm/tailwindcss@latest/dist/tailwind.min.css"),
Link(rel="stylesheet", href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/dist/tabler-icons.min.css"),
# ...additional head elements...
),
Body(
Div(
# Header with Flarebase text and icon tinted in warning color
Div(
Div(I(cls="ti ti-comet text-6xl text-warning"), "Flarebase", cls="text-5xl font-bold text-warning"),
P("Empowering you to build and manage lightweight backend systems effortlessly.", cls="text-xl mt-4"),
cls="text-center my-8"
),
# Descriptive section: convey project idea
Div(
P("Flarebase is a lightweight Backend-as-a-Service designed to simplify database management. With an intuitive user interface and a powerful RESTful API, you can deploy, manage, and scale your projects with ease.",
cls="max-w-2xl mx-auto text-center text-lg"),
cls="my-8"
),
# Hero cards for key benefits
Div(
Div(
Div(I(cls="ti ti-settings text-5xl text-warning")),
H2("Simplicity", cls="text-2xl mt-2 font-bold"),
P("Effortless setup and configuration."),
cls="card shadow-md p-4 rounded-lg text-center"
),
Div(
Div(I(cls="ti ti-rocket text-5xl text-warning")),
H2("Speed", cls="text-2xl mt-2 font-bold"),
P("Fast performance with minimal overhead."),
cls="card shadow-md p-4 rounded-lg text-center"
),
Div(
Div(I(cls="ti ti-currency-dollar text-5xl text-warning")),
H2("Affordability", cls="text-2xl mt-2 font-bold"),
P("Optimized resources at a low cost."),
cls="card shadow-md p-4 rounded-lg text-center"
),
cls="flex flex-col md:flex-row gap-6 justify-center my-8"
),
# Call-to-Action buttons
Div(
Button("Get Started", cls="btn btn-warning btn-outline m-2", hx_get="/", hx_target="body"),
Button("Documentation", cls="btn btn-warning btn-outline m-2", hx_get="/docs/Flarebase_Documentation", hx_target="body"),
cls="flex justify-center"
),
cls="container mx-auto p-4"
)
),
data_theme="dim",
style="min-height:100vh;"
)
# Start the server
serve()