News for hackers. Stuff that matters.
Re:Show HN: I built a Python web framework from scratch by evanharwin on Saturday September 09, 2023 @03:14PM (#37449234)
Wow I like it, simple like Flask, but with the HTML in the same file (as opposed to the jinja templates) which is a pattern I really like!

Makes me wonder if you could integrate this ambition to do the web-stuff in your Python file with the FastAPI/Pydantic BaseModel situation. Like a HTML templating library made out of Python data classes (or Pydantic BaseModels).

Either way, I respect the ambition! :) Always cool to see web stuff with Python.

Re:Show HN: I built a Python web framework from scratch by okasaki on Sunday September 10, 2023 @06:07AM (#37454425)
Flask's routes return strings, there's nothing stopping you from doing this. The render_template function is just a convenience.
Re:Show HN: I built a Python web framework from scratch by uranusjr on Sunday September 10, 2023 @10:39PM (#37462213)
Technically the string return type is just a shorthand, IIRC render_template returns a Response object that sets Content-Type and other things appropriately. But yeah it’s pretty trivial to create an HTML formatting library and use it with Flask. (I think there’s already libraries for the tag syntax, you just need to hook it into Flask, or literally any Python web framework really.)