[HN Gopher] Show HN: I built a Python web framework ___________________________________________________________________ Show HN: I built a Python web framework been working on this for nearly a year Author : zerointensity Score : 87 points Date : 2023-09-09 18:47 UTC (4 hours ago) (HTM) web link (github.com) (TXT) w3m dump (github.com) | evanharwin wrote: | 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. | brap wrote: | 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? | lifeisstillgood wrote: | Fantastic. Any working project brings value to the world. | | What did you learn from doing this one? | | What makes your framework different? | forgotpwd16 wrote: | 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. | nesarkvechnep wrote: | "modern" and "lightning fast" | hackan wrote: | -\\_(tsu)_/- | lozenge wrote: | 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 wrote: | 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? | earthboundkid wrote: | [flagged] | bowsamic wrote: | In what world is this an appropriate comment? | th0th wrote: | I really wonder what that dude was doing when he was 15 years | old, should have been a difficult childhood... | bowsamic wrote: | I get what he's going for I guess but "this isn't much of | an achievement" is sociopathic | Retr0id wrote: | To what does it owe its lightning fast-ness, and how does it | compare against other frameworks? | | Edit: It looks like some of the hot-paths are implemented in C. | Interesting! (I would recommend pointing this out in the readme) | ljlolel wrote: | Like Aaron Swartz's web.py | warthog wrote: | I would love something that combines FastAPI's simplicity for | setup with Django-like completeness and integrations | ilrwbwrkhv wrote: | What is missing from the web framework space is a headless ui | components merged with a db layer. Most of these frameworks | repeat old patterns. Nothing has been able to break through and | give us something truly revolutionary like Rails did. | | Web frameworks need to be a visual medium where you can create ui | using visual tools and the "backend" side of things merge | seamlessly. | askvictor wrote: | What do you mean by headless UI components? | ilrwbwrkhv wrote: | Basically the ui layer and the backend layer which and the | operational layer need to be combined into one seamless tool. | Right now you have the write a "frontend" and a "db | connection + backend logic layer". | | And by headless I mean something which builds on what the web | provides like buttons but adds a whole lot more of components | which are used but are unstyled. | bbkane wrote: | Sounds a bit like https://directus.io/ | syndicatedjelly wrote: | > Basically the ui layer and the backend layer which and | the operational layer need to be combined into one seamless | tool. Right now you have the write a "frontend" and a "db | connection + backend logic layer". | | Solving this "problem" just doesn't seem like a good use of | a time. There are now 4738484 different viable ways to | build a website, adding another way is just a waste of | everyone's time | MrLeap wrote: | Meteor was the last time I heard about something like this. | zzzeek wrote: | Then you've invented Visual Basic in the 90s, WordPress in | the 00s and I don't know Squarespace or something in the | last decade. For business cases beyond that, this is simply | not how "the backend" works. | dvdkon wrote: | Visual Basic and other "RAD" builders were pretty neat | and I think platforms like WordPress or Drupal never | captured their charm. For one, any apps built on them | need a rather complex runtime, which feels worse to me | than a language's standard library or the JVM. It's a far | cry from dragging in a button and then referencing it as | a variable in code. | | Second, the graphical niceties of these platforms often | run "in-process", and save what is basically code in the | same database as content. This will anger most Smalltalk | fans, but I think this style of development is a bad | idea. I want to know that some folder full of source code | is _the program_ , and some other folder is _the data_ , | and that if I back up one or the other, it will be | independently usable. | | I'm not saying 90s IDEs were perfect, but I don't think | there's been any successful successor to their style of | development. Graphical GUI builders exist, but they | usually don't support making web apps, and after working | with modern JS GUI frameworks, manually syncing GUI state | with app state seems antiquated and needlessly bug-prone. | I suppose QML with Qt Creator comes closest. | mabcat wrote: | VB was probably the charmingest language I've ever used, | especially for GUI. It takes the cake for "rather complex | runtime" though. As I recall, they bundled the entire VB | interpreter into every executable. This seemed scandalous | to me at the time. | gobdovan wrote: | maybe streamsync [0] comes close to what you describe? | | "Streamsync is an open-source framework for creating data apps. | Build user interfaces using a visual editor; write the backend | code in Python." [0] https://github.com/streamsync- | cloud/streamsync | rmbyrro wrote: | Congrats on launching a working product! | | What's the rationale behind view.py? | alrs wrote: | "modern" | 29athrowaway wrote: | Python is great when your goal is to have the highest | environmental footprint. | megalord wrote: | Yeah, because when we implement it in C++ we surely are going | to save the planet now. | 29athrowaway wrote: | Or Julia, or one of the many options you have if the | community was more open minded. | phas0ruk wrote: | Flask is decent. Can't we use that? | mhd wrote: | Whatever happened to web2py? I remember that being brought up a | lot in these discussions... | blooalien wrote: | I agree. Flask is quite nice, as are some of the other things | based off it, like FastAPI, and some of the Flask-inspired | async frameworks, and the Jinja template engine that Flask | uses. All good stuff. | nomdep wrote: | You can use whatever you want, can't you? | | However, my opinion is that is a PITA that every Flask project | has a different structure, unlike a "batteries included" | framework like Django, Rails, etc. | revskill wrote: | Definition of "modern" ? | dvektor wrote: | Are you really 15yrs old? | | is the biggest question here.. | frodowtf wrote: | As a 13 year old, I can confirm that we always mention our age | before anyone asks. | forgotpwd16 wrote: | Have noticed that teens tend to indeed say they're x old on | stuff they're doing. | dvektor wrote: | And he's been working on it for a year. So he built a web | framework at 14. | | And I can't center a div without a google search... | | (I am a back-end dev tho, so its a little better than it | sounds) | Semiapies wrote: | Probably safest to avoid people raining hate in them for any | perceived falling. | matsemann wrote: | Can't see they did it here, though. You have to click into | their profile to see it. ___________________________________________________________________ (page generated 2023-09-09 23:00 UTC)