Skip to content

Commit e251256

Browse files
committed
Site generated at Fri 6 Sep 2024 18:36:28 BST
1 parent 1d179d4 commit e251256

2 files changed

Lines changed: 70 additions & 4 deletions

File tree

blog/2024/09/06/thoughts-on-fasthtml/index.html

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@
322322
<h1 itemprop="name headline">Thoughts on FastHTML</h1>
323323
<p class="post-meta"><time datetime="2024-09-06T12:45:00+01:00" itemprop="datePublished">Sep 6, 2024</time></p>
324324
<div class="post-content" itemprop="articleBody">
325-
<p>I’ve been working on building a chat application that required complex visualizations and interactions. Initially, I decided to try out FastHTML for this project.</p>
325+
<p><img src="https://stacktoheap.com/images/fasthtml.jpg" width="686px" height="386px" /></p>
326+
327+
<p>I’ve been working on building a chat application that required complex visualizations and interactions. Initially, I decided to try out FastHTML for this project.</p>
326328

327329
<p>FastHTML, combined with htmx, seemed like a promising stack, especially with its modern approach to handling dynamic web content. However, after spending considerable time with it, I found myself at a crossroads.</p>
328330

@@ -342,6 +344,37 @@ <h2 id="the-downside-of-writing-views-in-python">The Downside of Writing Views i
342344

343345
<p>Another factor that contributed to my decision was the way views are written in FastHTML—using Python. Initially, I found this approach intriguing; it’s not every day you get to write your front-end code in Python without any Javascript or Typescript. But as the project grew, it became tedious. The novelty wore off, and I realized that separating concerns with a JavaScript-based front-end made more sense for the complexity I was dealing with.</p>
344346

347+
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">Body</span><span class="p">(</span>
348+
349+
<span class="n">Div</span><span class="p">(</span>
350+
<span class="n">Div</span><span class="p">(</span>
351+
<span class="n">H1</span><span class="p">(</span><span class="s">'Chat Bot'</span><span class="p">),</span>
352+
<span class="n">Div</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">ChatMessage</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="n">messages</span><span class="p">],</span> <span class="nb">id</span><span class="o">=</span><span class="s">"chatlist"</span><span class="p">,</span> <span class="n">cls</span><span class="o">=</span><span class="s">"chat-box h-[85vh] overflow-y-auto"</span><span class="p">),</span>
353+
<span class="n">Form</span><span class="p">(</span><span class="n">Group</span><span class="p">(</span><span class="n">ChatInput</span><span class="p">(),</span> <span class="n">Button</span><span class="p">(</span><span class="s">"Send"</span><span class="p">,</span> <span class="n">cls</span><span class="o">=</span><span class="s">"btn btn-primary"</span><span class="p">)),</span>
354+
<span class="n">hx_post</span><span class="o">=</span><span class="s">"/"</span><span class="p">,</span> <span class="n">hx_target</span><span class="o">=</span><span class="s">"#chatlist"</span><span class="p">,</span> <span class="n">hx_swap</span><span class="o">=</span><span class="s">"beforeend"</span><span class="p">,</span>
355+
<span class="n">cls</span><span class="o">=</span><span class="s">""</span><span class="p">,</span>
356+
<span class="p">),</span>
357+
<span class="n">cls</span> <span class="o">=</span> <span class="s">"pt-4 pl-4"</span>
358+
<span class="p">),</span>
359+
360+
<span class="n">Div</span><span class="p">(</span>
361+
<span class="n">Div</span><span class="p">(</span>
362+
<span class="n">A</span><span class="p">(</span><span class="s">"Agent DAG"</span><span class="p">,</span> <span class="n">role</span><span class="o">=</span><span class="s">"tab"</span><span class="p">,</span> <span class="n">cls</span><span class="o">=</span><span class="s">"tab tab-active"</span><span class="p">),</span>
363+
<span class="n">A</span><span class="p">(</span><span class="s">"Agent Conversaion"</span><span class="p">,</span> <span class="n">role</span><span class="o">=</span><span class="s">"tab"</span><span class="p">,</span> <span class="n">cls</span><span class="o">=</span><span class="s">"tab"</span><span class="p">),</span>
364+
<span class="n">A</span><span class="p">(</span><span class="s">"LLM Traces"</span><span class="p">,</span> <span class="n">role</span><span class="o">=</span><span class="s">"tab"</span><span class="p">,</span> <span class="n">cls</span><span class="o">=</span><span class="s">"tab"</span><span class="p">),</span>
365+
<span class="n">role</span><span class="o">=</span><span class="s">"tablist"</span><span class="p">,</span> <span class="n">cls</span><span class="o">=</span><span class="s">"tabs tabs-boxed"</span>
366+
<span class="p">),</span>
367+
<span class="n">Div</span><span class="p">(</span>
368+
<span class="n">Div</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="s">"agentdag"</span><span class="p">),</span>
369+
<span class="n">cls</span> <span class="o">=</span> <span class="s">"p-4"</span>
370+
<span class="p">),</span>
371+
<span class="n">cls</span> <span class="o">=</span> <span class="s">"p-4"</span><span class="p">),</span>
372+
<span class="n">cls</span> <span class="o">=</span> <span class="s">"grid grid-cols-2 divide-x divide-primary"</span>
373+
<span class="p">),</span>
374+
<span class="n">cls</span> <span class="o">=</span> <span class="s">""</span>
375+
<span class="p">)</span>
376+
</code></pre></div></div>
377+
345378
<h2 id="transitioning-to-svelte">Transitioning to Svelte</h2>
346379

347380
<p>After wrestling with FastHTML for a while, I decided it was time to pivot. Svelte had been on my radar for quite some time, and the features provided by SvelteFlow (a framework visualizing flows with drag and drop nodes) were exactly what I needed for my project.</p>

feed.xml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
</description>
77
<link>https://stacktoheap.com/</link>
88
<atom:link href="https://stacktoheap.com/feed.xml" rel="self" type="application/rss+xml"/>
9-
<pubDate>Fri, 06 Sep 2024 18:31:22 +0100</pubDate>
10-
<lastBuildDate>Fri, 06 Sep 2024 18:31:22 +0100</lastBuildDate>
9+
<pubDate>Fri, 06 Sep 2024 18:36:23 +0100</pubDate>
10+
<lastBuildDate>Fri, 06 Sep 2024 18:36:23 +0100</lastBuildDate>
1111
<generator>Jekyll v3.9.5</generator>
1212

1313
<item>
1414
<title>Thoughts on FastHTML</title>
15-
<description>&lt;p&gt;I’ve been working on building a chat application that required complex visualizations and interactions. Initially, I decided to try out FastHTML for this project.&lt;/p&gt;
15+
<description>&lt;p&gt;&lt;img src=&quot;https://stacktoheap.com/images/fasthtml.jpg&quot; width=&quot;686px&quot; height=&quot;386px&quot; /&gt;&lt;/p&gt;
16+
17+
&lt;p&gt;I’ve been working on building a chat application that required complex visualizations and interactions. Initially, I decided to try out FastHTML for this project.&lt;/p&gt;
1618

1719
&lt;p&gt;FastHTML, combined with htmx, seemed like a promising stack, especially with its modern approach to handling dynamic web content. However, after spending considerable time with it, I found myself at a crossroads.&lt;/p&gt;
1820

@@ -32,6 +34,37 @@
3234

3335
&lt;p&gt;Another factor that contributed to my decision was the way views are written in FastHTML—using Python. Initially, I found this approach intriguing; it’s not every day you get to write your front-end code in Python without any Javascript or Typescript. But as the project grew, it became tedious. The novelty wore off, and I realized that separating concerns with a JavaScript-based front-end made more sense for the complexity I was dealing with.&lt;/p&gt;
3436

37+
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
38+
39+
&lt;span class=&quot;n&quot;&gt;Div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
40+
&lt;span class=&quot;n&quot;&gt;Div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
41+
&lt;span class=&quot;n&quot;&gt;H1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Chat Bot'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
42+
&lt;span class=&quot;n&quot;&gt;Div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ChatMessage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;chatlist&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;chat-box h-[85vh] overflow-y-auto&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
43+
&lt;span class=&quot;n&quot;&gt;Form&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ChatInput&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Send&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;btn btn-primary&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt;
44+
&lt;span class=&quot;n&quot;&gt;hx_post&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hx_target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;#chatlist&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hx_swap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;beforeend&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
45+
&lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
46+
&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
47+
&lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;pt-4 pl-4&quot;&lt;/span&gt;
48+
&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
49+
50+
&lt;span class=&quot;n&quot;&gt;Div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
51+
&lt;span class=&quot;n&quot;&gt;Div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
52+
&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Agent DAG&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tab&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tab tab-active&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
53+
&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Agent Conversaion&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tab&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tab&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
54+
&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;LLM Traces&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tab&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tab&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
55+
&lt;span class=&quot;n&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tablist&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tabs tabs-boxed&quot;&lt;/span&gt;
56+
&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
57+
&lt;span class=&quot;n&quot;&gt;Div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
58+
&lt;span class=&quot;n&quot;&gt;Div&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;agentdag&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
59+
&lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;p-4&quot;&lt;/span&gt;
60+
&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
61+
&lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;p-4&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
62+
&lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;grid grid-cols-2 divide-x divide-primary&quot;&lt;/span&gt;
63+
&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
64+
&lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;
65+
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
66+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
67+
3568
&lt;h2 id=&quot;transitioning-to-svelte&quot;&gt;Transitioning to Svelte&lt;/h2&gt;
3669

3770
&lt;p&gt;After wrestling with FastHTML for a while, I decided it was time to pivot. Svelte had been on my radar for quite some time, and the features provided by SvelteFlow (a framework visualizing flows with drag and drop nodes) were exactly what I needed for my project.&lt;/p&gt;

0 commit comments

Comments
 (0)