Skip to content

Commit 621d27c

Browse files
committed
fixes #5
1 parent c0778dd commit 621d27c

File tree

8 files changed

+58
-21
lines changed

8 files changed

+58
-21
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
<!-- do not remove -->
44

5+
## 0.0.9
6+
7+
### New Features
8+
9+
- add railway cli link command ([#4](https://github.com/AnswerDotAI/fasthtml/issues/4))
10+
11+
12+
513

614
## 0.0.5
715

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include *.pyi
12
include settings.ini
23
include LICENSE
34
include CONTRIBUTING.md

fasthtml/_modidx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'fasthtml/components.py'),
1414
'fasthtml.components._FindElems.handle_starttag': ( 'components.html#_findelems.handle_starttag',
1515
'fasthtml/components.py'),
16+
'fasthtml.components.__getattr__': ('components.html#__getattr__', 'fasthtml/components.py'),
1617
'fasthtml.components.fill_dataclass': ('components.html#fill_dataclass', 'fasthtml/components.py'),
1718
'fasthtml.components.fill_form': ('components.html#fill_form', 'fasthtml/components.py'),
1819
'fasthtml.components.find_elems': ('components.html#find_elems', 'fasthtml/components.py'),

fasthtml/cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
@call_parse
1414
def railway_link():
1515
t = run("railway status --json".split(), capture_output=True)
16-
print(t.stdout.decode())
1716
j = json.loads(t.stdout)
1817
prj = j['id']
1918
idxpath = 'edges', 0, 'node', 'id'
2019
env = nested_idx(j, 'environments', *idxpath)
2120
svc = nested_idx(j, 'services', *idxpath)
2221

2322
cmd = f"railway link -e {env} -p {prj} -s {svc}"
24-
print(cmd)
2523
res = run(cmd.split(), capture_output=True)

fasthtml/components.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,9 @@ def find_elems(s:XT|str, tag=None, attr=None, **props):
113113
o = _FindElems(tag, attr, **props)
114114
o.feed(to_xml(s))
115115
return o.res
116+
117+
# %% ../nbs/01_components.ipynb 23
118+
def __getattr__(tag):
119+
if tag.startswith('_') or tag[0].islower(): raise AttributeError
120+
def _f(*c, target_id=None, **kwargs): return xt_hx(tag, *c, target_id=target_id, **kwargs)
121+
return _f

nbs/01_components.ipynb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,20 @@
419419
"elem.xpath(\"//input[@id='title']/@value\")"
420420
]
421421
},
422+
{
423+
"cell_type": "code",
424+
"execution_count": null,
425+
"id": "1d8a28b1",
426+
"metadata": {},
427+
"outputs": [],
428+
"source": [
429+
"#| export\n",
430+
"def __getattr__(tag):\n",
431+
" if tag.startswith('_') or tag[0].islower(): raise AttributeError\n",
432+
" def _f(*c, target_id=None, **kwargs): return xt_hx(tag, *c, target_id=target_id, **kwargs)\n",
433+
" return _f"
434+
]
435+
},
422436
{
423437
"cell_type": "markdown",
424438
"id": "474e14b4",

nbs/04_cli.ipynb

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"id": "b73068da",
77
"metadata": {},
88
"outputs": [],
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"cell_type": "code",
15-
"execution_count": 15,
15+
"execution_count": null,
1616
"id": "acfbc502",
1717
"metadata": {},
1818
"outputs": [],
@@ -55,7 +55,7 @@
5555
},
5656
{
5757
"cell_type": "code",
58-
"execution_count": 24,
58+
"execution_count": null,
5959
"id": "d211e8e2",
6060
"metadata": {},
6161
"outputs": [],
@@ -75,21 +75,9 @@
7575
],
7676
"metadata": {
7777
"kernelspec": {
78-
"display_name": "Python 3 (ipykernel)",
78+
"display_name": "python3",
7979
"language": "python",
8080
"name": "python3"
81-
},
82-
"language_info": {
83-
"codemirror_mode": {
84-
"name": "ipython",
85-
"version": 3
86-
},
87-
"file_extension": ".py",
88-
"mimetype": "text/x-python",
89-
"name": "python",
90-
"nbconvert_exporter": "python",
91-
"pygments_lexer": "ipython3",
92-
"version": "3.11.8"
9381
}
9482
},
9583
"nbformat": 4,

nbs/index.ipynb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,28 @@
3636
"```"
3737
]
3838
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {},
42+
"source": [
43+
"For a minimal app, create a file \"main.py\" as follows:\n",
44+
"\n",
45+
"```{.python filename=\"main.py\"}\n",
46+
"from fasthtml.all import *\n",
47+
"import uvicorn\n",
48+
"\n",
49+
"app = FastHTML()\n",
50+
"rt = app.route\n",
51+
"\n",
52+
"@rt(\"/\")\n",
53+
"def get():\n",
54+
" return Title(\"FastHTML\"), H1(\"Hello World!\")\n",
55+
"\n",
56+
"if __name__ == '__main__':\n",
57+
" uvicorn.run(app, host='0.0.0.0', port=int(os.getenv(\"PORT\", default=8000)))\n",
58+
"```"
59+
]
60+
},
3961
{
4062
"cell_type": "markdown",
4163
"metadata": {},
@@ -47,7 +69,7 @@
4769
"cell_type": "markdown",
4870
"metadata": {},
4971
"source": [
50-
"Import `fasthtml`, and you'll probably want the widgets from `fastcore.xml` too."
72+
"Import from `fasthtml.all`:"
5173
]
5274
},
5375
{
@@ -56,8 +78,7 @@
5678
"metadata": {},
5779
"outputs": [],
5880
"source": [
59-
"from fasthtml import *\n",
60-
"from fastcore.xml import *"
81+
"from fasthtml.all import *"
6182
]
6283
},
6384
{

0 commit comments

Comments
 (0)