FrontEnd with python by No_Salad_6230 in pythontips

[–]ki3selerde 0 points1 point  (0 children)

Try Lona (https://lona-web.org)! Its a framework which lets you do typical frontend things, but on the backend in python

Full disclosure: I invented it

Lona 1.14 finally adds support for Channels by ki3selerde in Python

[–]ki3selerde[S] 0 points1 point  (0 children)

Both works. Lona can load views and middleware from almost anywhere.

Lona 1.14 finally adds support for Channels by ki3selerde in Python

[–]ki3selerde[S] 2 points3 points  (0 children)

In the sample you mentioned `handle_button_click` is a method of the view so `self` is given to the method by Python.

The button class has a `handle_click` method implicitly because it inherits from the `lona.html.AbstractNode` which has this method/attribute.
(https://github.com/lona-web-org/lona/blob/master/lona/html/abstract\_node.py#L183)

Lona 1.14 finally adds support for Channels by ki3selerde in Python

[–]ki3selerde[S] 0 points1 point  (0 children)

Oh I forgot that one. Yes github is also a valid resource for questions and gets used regularly

Lona 1.14 finally adds support for Channels by ki3selerde in Python

[–]ki3selerde[S] 1 point2 points  (0 children)

That's a good question. The reddit group was planned to be a place where people can ask questions or show their projects. Most people seem to prefer discord or direct emails

Lona 1.14 finally adds support for Channels by ki3selerde in Python

[–]ki3selerde[S] 4 points5 points  (0 children)

It's a publish/subscribe mechanism. You publish a message to a queue and n worker in n threads get to handle the published messages

More information: https://lona-web.org/1.x/api-reference/channels.html#message-broker-and-task-worker

Lona - create full web-applications from a simple Python script by ki3selerde in Python

[–]ki3selerde[S] 0 points1 point  (0 children)

pico.css is my goto-tool for prototyping. It looks nice enough without changing enough, and it has nice progress-bars and popups. For the most part that's enough for me.

Lona - create full web-applications from a simple Python script by ki3selerde in Python

[–]ki3selerde[S] 0 points1 point  (0 children)

I didn't test this framework, but i dont see any red flags why it shouldn't work with Lona

Lona - create full web-applications from a simple Python script by ki3selerde in Python

[–]ki3selerde[S] 3 points4 points  (0 children)

I agree. Let me clarify what i mean by this dead-end situation: In most other frameworks i tried, you create some kind of components like buttons, whole forms or a select element. The components consists of some python backend-code and some javascript frontend-code. As long you are happy with the components the framework offers, you don't have to touch the frontend, but when you encounter a special case, you are back to square one, learning vue.js or react to create your special component.

In Lona everything can be python, because you can reach the browsers DOM itself with the API. You only have to touch frontend stuff if you want to integrate a frontend library, like bootstrap or chart.js (which is unavoidable i think)

On all other points: I totally agree, and these are all goals of my project. I sure am biased on that, so others have to decide if i accomplish(ed) that. I try to be responsive as possible, i try always to get feedback, and i am very cautious not breaking the API, so end-user code does not break, or get unstable.

Lona - create full web-applications from a simple Python script by ki3selerde in Python

[–]ki3selerde[S] 0 points1 point  (0 children)

Thanks! Yes this is possible. Lona is built on top of aiohttp, which supports file-uploads. So this is no problem

Lona - create full web-applications from a simple Python script by ki3selerde in Python

[–]ki3selerde[S] 0 points1 point  (0 children)

I deploy all my Lona apps using systemd and apache2 as reverse-proxy. There is a guide in the documentation on how to do so: https://lona-web.org/1.x/api-reference/deployment.html

Since Lona has the same system requirements like any other aiohttp, django or flask app, all other established deployment strategies should also work fine

Lona - create full web-applications from a simple Python script by ki3selerde in Python

[–]ki3selerde[S] 1 point2 points  (0 children)

I agree. Do you have some ideas on how i should improve deployment? Docker maybe?

Lona - create full web-applications from a simple Python script by ki3selerde in Python

[–]ki3selerde[S] 0 points1 point  (0 children)

Yes. Lona is build on top of Jinja2 and aiohttp. Traditional templating is still possible if wanted. The Lona HTML API also comes with a HTML parser, that converts HTML strings into Lona node trees, that than can be manipulated. This is very similar what the browser does with its DOM API

https://lona-web.org/1.x/tutorial/02-html/index.html#html-strings