TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Generate styled web pages with just Python

229 pointsby zainhodaabout 2 years ago
There are a lot of Python to web app frameworks going around these days but I wanted something that was a little more lightweight that just generates HTML pages and can be embedded in Flask or other Python web servers incrementally.<p>PyVibe uses Python components to construct a page with styling that you can use in Flask, in a static site, or even in Pyodide.

25 comments

andrewfromxabout 2 years ago
I noticed:<p>&lt;script src=&quot;<a href="https:&#x2F;&#x2F;cdn.tailwindcss.com&quot;&gt;&lt;&#x2F;script&gt;" rel="nofollow">https:&#x2F;&#x2F;cdn.tailwindcss.com&quot;&gt;&lt;&#x2F;script&gt;</a><p>in the source of the homepage. Just FYI the tailwind people say that&#x27;s just for dev mode and never deploy that to prod. Instead you gotta run something like:<p>npx tailwindcss -o ..&#x2F;assets&#x2F;css&#x2F;tail.min.css --minify<p>and then replace the script with:<p>&lt;link rel=&quot;stylesheet&quot; type=&quot;text&#x2F;css&quot; href=&quot;&#x2F;assets&#x2F;css&#x2F;tail.min.css&quot;&gt;<p>&quot;a script referred to as the Tailwind Play CDN. This script is only to be used for learning and experimenting, never for a live site.&quot;<p>from <a href="https:&#x2F;&#x2F;www.codeinwp.com&#x2F;blog&#x2F;tailwind-css-tutorial&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.codeinwp.com&#x2F;blog&#x2F;tailwind-css-tutorial&#x2F;</a>
评论 #35257171 未加载
评论 #35258525 未加载
chatmastaabout 2 years ago
I love new technology, and this is really cool. I don&#x27;t want to derail the discussion too much, but I&#x27;ve noticed this trend of &quot;making web dev easier with just Python&quot; - e.g. htmx, pynecone, streamlit, etc. The common theme seems to be magically hiding JS from the developer.<p>Can any python devs who use these tools explain the appeal? Do you just have an aversion to JS? And how do you reconcile that with the fact that, at the end of the day, your code is running in the browser as JS, CSS, and HTML? As soon as you need to debug something, you&#x27;ll be a fish out of water. To me that sounds like a &quot;worst of both worlds&quot; kind of situation.<p>Is JS really <i>that</i> bad?
评论 #35262510 未加载
评论 #35261183 未加载
评论 #35262323 未加载
评论 #35261281 未加载
评论 #35276609 未加载
davidegabout 2 years ago
As someone who knows Python and always has to google CSS properties and javascript functions, this is a really sweet little project! I&#x27;m not going to reach for this if I need to have a website that needs to look a very specific way, but for cranking something out to display some data or documentation, this seems really nice.
评论 #35256746 未加载
mwnabout 2 years ago
Interesting. I’ll try it out with my students. Doing HTML and CSS in a Flask app seems advanced to them. I can recommend a “deploy to PythonAnywhere” guide so users can get it online. That would require your module to be part of PythonAnywhere’s environment.
评论 #35259701 未加载
评论 #35260913 未加载
jensenboxabout 2 years ago
This reminds me of <a href="https:&#x2F;&#x2F;pynecone.io">https:&#x2F;&#x2F;pynecone.io</a><p>I would love to see these merge somehow if possible.
评论 #35259073 未加载
akxabout 2 years ago
Mmm, looks like the library doesn&#x27;t do any escaping for content (and doesn&#x27;t offer a way to do that either)?
评论 #35259129 未加载
chrispogeekabout 2 years ago
So cool! Is there support for layouts?<p>Edit: Aw broken link - <a href="https:&#x2F;&#x2F;www.pycob.com&#x2F;components" rel="nofollow">https:&#x2F;&#x2F;www.pycob.com&#x2F;components</a><p>Edit: Nevermind, found it - <a href="https:&#x2F;&#x2F;www.pyvibe.com&#x2F;component_reference.html" rel="nofollow">https:&#x2F;&#x2F;www.pyvibe.com&#x2F;component_reference.html</a>
评论 #35256669 未加载
评论 #35259118 未加载
macnabasabout 2 years ago
The HTML markup in the form example is not valid. Label for attributes correspond to the input&#x27;s id – not its name.<p>I&#x27;d be really hesitant using a technology that abstracts away something as fundamental as HTML. You&#x27;re putting a lot of faith and trust into a library that will make mistakes that you can&#x27;t fix.
Bob2077about 2 years ago
I&#x27;m curious about the performance implications of using a Python-centric approach for creating web pages. Would the generated HTML pages be as efficient and optimized as those created with traditional web development techniques?
评论 #35256983 未加载
nurettinabout 2 years ago
I wonder what it would look like if websocket support was added. Perhaps add_* would return Sink objects which would have appropriate update methods that could be called in another thread? But that would require a page.run() function
评论 #35268360 未加载
评论 #35256823 未加载
pietzabout 2 years ago
I&#x27;m just not convinced how useful this will be. On one side you&#x27;re very limited to the default style and list of available components. On the otger side you have to learn a new framework. It seems to me if you invest the time into a static web framework instead, you can design sites like this just as quickly while being able to dig deeper into html and css whenever you need to.
评论 #35264044 未加载
keithalewisabout 2 years ago
Doing an A&#x2F;B test on the Python source and the generated html I don&#x27;t see much difference when I squint my eyes. Why drag Python into this?
评论 #35256336 未加载
aitchnyuabout 2 years ago
JSX, Vue, or even django templates spoiled me so this imperative Python syntax sends my eyes spinning and I cant even think about reading somebody&#x27;s nested loops. Has anybody got used to this syntax for complex layouts? Or has anybody made a templating language for this?
DaanDLabout 2 years ago
What problem does this solve? I mean, we have these kinds of frameworks&#x2F;libraries for decades now...
评论 #35259116 未加载
jasfiabout 2 years ago
I&#x27;m planning to add something like this to <a href="https:&#x2F;&#x2F;inventai.xyz" rel="nofollow">https:&#x2F;&#x2F;inventai.xyz</a>. Subscriptions aren&#x27;t ready, so you can&#x27;t actually generate anything yet.
评论 #35257186 未加载
winddudeabout 2 years ago
Interesting. Cool to see python becoming more &quot;full-stack&quot;
评论 #35259104 未加载
thedanglerabout 2 years ago
This is cool. Good work.
评论 #35255744 未加载
drBonkersabout 2 years ago
What&#x27;s the difference between PyVibe and PyCob?
评论 #35256845 未加载
jollyllamaabout 2 years ago
It sounds like you&#x27;re talking about Jinja? Check out the includes &#x2F; extends directives.<p>Also, look into HTMX.
dopidopHNabout 2 years ago
Hey. I will try it in a upcoming hackathon!
评论 #35256346 未加载
xceejayabout 2 years ago
On of the best programs for linux tbh
iamcreasyabout 2 years ago
Interesting. Does it dump the HTML&#x2F;CSS and then someone needs to go in and add interaction?
评论 #35260394 未加载
wodenokotoabout 2 years ago
Is this a competitor to streamlit?
评论 #35259094 未加载
ar9avabout 2 years ago
It&#x27;s bit odd. You would want the form to be handled by Django forms system or wtforms in Flask - and having third party package to provice CSS for the classes they used (or you use on a wrapper element).<p>And you can make reusable components with Jinja or Django templates as well.
Zurrrrrabout 2 years ago
This is really really nice!
评论 #35255743 未加载