3 ms·
I started learning FastHTML but somebody on reddit mentioned htpy. In my opinion htpy+fastapi is awesome combo. I like the way htpy handles declaring html compo
by mlboss 2y ago
I started learning FastHTML but somebody on reddit mentioned htpy. In my opinion htpy+fastapi is awesome combo. I like the way htpy handles declaring html components.
http://htpy.dev http://htpy.dev
- prabhu-yu 2y agoThank you for the link!
- _AzMoo 2y agoWhy would you use fastapi if you're rendering with htpy, instead of just using Starlette?
- ledgerdev 2y agoI would like to know this also.
- riezebos 2y agoI've used FastAPI, but haven't done a lot with Starlette directly. If you are building a full stack app, I can imagine the integration between FastAPI and Pydantic can make it easier to work with the data that you might want to render in the HTML that you generate using htpy?
- _AzMoo 2y agohtpy is just server-side rendering of HTML. Your routes are returning strings instead of structured data, so from the perspective of responses you're not going to be using Pydantic at all. That doesn't stop you from using it to validate objects you're passing around in your server, but I personally wouldn't do that because Pydantic can have a pretty hefty memory footprint. I've seen over-reliance on pydantic lead to plenty of OOMKilled errors. It's a bit different for requests though. FastAPI will allow you to define your request schema (application/json or application/x-www-form-urlencoded) and validate it using pydantic, but starlette doesn't do that OOtB. It's trivial to implement though, and if it were me I would probably choose to do that rather than deal with FastAPI's inflexibility.
- flockonus 2y agoI don't quite get an abstraction like this, if in the end both in our minds and through [trans|com]piler it's necessary to know the underlying abstraction in details(?)
- IanCal 2y agoThe benefit comes as you're generating chunks in python, then you're passing around python objects rather than strings, string templates, etc. It's also a bit of an odd thing to be in python, then just because you need to loop you need to write Jinja or other templates which are different languages basically. Might be nicer to write a loop in python.
- zero0529 2y agoAlways wondered why there doesn’t exist a pyx like there exist a jsx/tsx. Is it just not feasible
- zepolen 2y agoSomething similar already exists: https://github.com/pyxl4/pyxl4?tab=readme-ov-file#inline-python-expressions https://github.com/pyxl4/pyxl4?tab=readme-ov-file#inline-pyt... It's a shitty experience.
- aitchnyu 2y agoI have a feeling the Python Template Industrial Complex; which includes Jinja, tag(anothertag("text")) DSLs, GVR's pyxl3, Kivy UI language; will all go away if Python has something as convenient as JSX.