Readit News logoReadit News
evanharwin · 2 years ago
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.

okasaki · 2 years ago
Flask's routes return strings, there's nothing stopping you from doing this. The render_template function is just a convenience.
uranusjr · 2 years ago
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.)
brap · 2 years ago
I went over the docs and couldn’t find anything about state management and client/server actions.

I’m guessing this would be similar to LiveView? If so, I’m not sure Python will handle the concurrency as well as Elixir…

Edit: I see now that the goal is to compile this to JS, so I’m assuming it’s going to be quite the opposite of LiveView and will do everything on the client?

kreetx · 2 years ago
This looks like the regular server side web framework with helpers to create html. State is (likely) managed by using the appropriate python library, or just a global variable or dict if race conditions don’t matter.
brap · 2 years ago
Then why compile to JS? And what happens when the client performs any actions, e.g clicks a button that should send an outgoing request either from the client or from the server?
lifeisstillgood · 2 years ago
Fantastic. Any working project brings value to the world.

What did you learn from doing this one?

What makes your framework different?

forgotpwd16 · 2 years ago
Would like to see a simple site built on it besides basic examples (can even be used as a tutorial to the framework). The components seem interesting but feels like will quickly get complex.
warthog · 2 years ago
I would love something that combines FastAPI's simplicity for setup with Django-like completeness and integrations
barapa · 2 years ago
Litestar may be closer https://litestar.dev/
warthog · 2 years ago
wow this looks so great - thank you!
lozenge · 2 years ago
I would say, focus on what makes your web framework different.

i.e. if you want to implement py-to-js, don't also reinvent routing at the same time. Grab an existing py-to-js engine and make something tiny with it. If it shows the value of the idea, then it will be picked up by the wider community.

I like the idea of decorators for turning query and body parameters into function parameters, I haven't seen that before, however is there a syntax where I can specify many parameters without taking many LOC?

For example you could have ``@query("name", "age")`` and look at the function signature using the 'inspect' module to determine that name should be a str and age an int. Or maybe ``@query(name=str, age=int)`` .

Also, mention it uses ASGI in the docs, so people are reassured on how to deploy it. And list that it is already compatible with uvicorn and etc.

matsemann · 2 years ago
The decorator for body params reminds me a bit of Spring's @RequestBody annotation.

However, fastapi manages this without a decorator, only a type hint. Is there any gain doing it like this?

lozenge · 2 years ago
It's nice to have explicit demarcation whether the parameter is coming in from the query string or request body.
ljlolel · 2 years ago
Like Aaron Swartz’s web.py
raybb · 2 years ago
Which is still somewhat maintained by folks from Internet Archive because it's used by Open Library. I'm not entirely sure what the benefit is to using that library but it sure is a PITA to Google about with a name like that.
zero-g · 2 years ago
Really cool! Why did you decide to start working on it? Because you wanted something simpler than what already exists, or just curiosity?