Spaces:
Running
Running
feat: Add twitter card
Browse files- .gitignore +2 -1
- public/social.png +0 -0
- src/tutorial/__init__.py +19 -5
.gitignore
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
.sesskey
|
2 |
*.ipynb
|
3 |
__pycache__
|
4 |
-
.venv
|
|
|
|
1 |
.sesskey
|
2 |
*.ipynb
|
3 |
__pycache__
|
4 |
+
.venv
|
5 |
+
.DS_Store
|
public/social.png
ADDED
![]() |
src/tutorial/__init__.py
CHANGED
@@ -13,17 +13,20 @@ from fasthtml.common import (
|
|
13 |
Div,
|
14 |
Hgroup,
|
15 |
HighlightJS,
|
|
|
16 |
Iframe,
|
17 |
Main,
|
18 |
MarkdownJS,
|
19 |
P,
|
20 |
Pre,
|
21 |
Script,
|
|
|
22 |
Table,
|
23 |
Tbody,
|
24 |
Td,
|
25 |
Th,
|
26 |
Thead,
|
|
|
27 |
Tr,
|
28 |
fast_app,
|
29 |
serve,
|
@@ -32,6 +35,14 @@ from fasthtml.common import (
|
|
32 |
hdrs = (
|
33 |
MarkdownJS(),
|
34 |
HighlightJS(langs=["python", "javascript", "html", "css"]),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
)
|
36 |
app, rt = fast_app(hdrs=hdrs, static_path="public")
|
37 |
|
@@ -50,11 +61,14 @@ The code can be found on [GitHub](https://github.com/phihung/fasthtml_examples).
|
|
50 |
@app.get("/")
|
51 |
def homepage():
|
52 |
ls = [get_example(name) for name in examples]
|
53 |
-
return
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
58 |
),
|
59 |
)
|
60 |
|
|
|
13 |
Div,
|
14 |
Hgroup,
|
15 |
HighlightJS,
|
16 |
+
Html,
|
17 |
Iframe,
|
18 |
Main,
|
19 |
MarkdownJS,
|
20 |
P,
|
21 |
Pre,
|
22 |
Script,
|
23 |
+
Socials,
|
24 |
Table,
|
25 |
Tbody,
|
26 |
Td,
|
27 |
Th,
|
28 |
Thead,
|
29 |
+
Title,
|
30 |
Tr,
|
31 |
fast_app,
|
32 |
serve,
|
|
|
35 |
hdrs = (
|
36 |
MarkdownJS(),
|
37 |
HighlightJS(langs=["python", "javascript", "html", "css"]),
|
38 |
+
*Socials(
|
39 |
+
title="HTMX examples with FastHTML",
|
40 |
+
description="Reproduction of HTMX official examples with Python FastHTML",
|
41 |
+
site_name="phihung-htmx-examples.hf.space",
|
42 |
+
twitter_site="@hunglp",
|
43 |
+
image="/social.png",
|
44 |
+
url="https://phihung-htmx-examples.hf.space",
|
45 |
+
),
|
46 |
)
|
47 |
app, rt = fast_app(hdrs=hdrs, static_path="public")
|
48 |
|
|
|
61 |
@app.get("/")
|
62 |
def homepage():
|
63 |
ls = [get_example(name) for name in examples]
|
64 |
+
return (
|
65 |
+
Title("HTMX examples with FastHTML"),
|
66 |
+
Main(cls="container")(
|
67 |
+
Div(INTRO, cls="marked"),
|
68 |
+
Table(
|
69 |
+
Thead(Tr(Th("Pattern"), Th("Description"))),
|
70 |
+
Tbody(tuple(Tr(Td(A(ex.title, href="/" + ex.slug)), Td(ex.desc)) for ex in ls)),
|
71 |
+
),
|
72 |
),
|
73 |
)
|
74 |
|