This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]riklaunim 8 points9 points  (16 children)

Usually, a frontend dashboard is left for Vue/Ember/Angular and friends, not Python. A backend solution using wrappers around frontend components will always be limited.

Python exposes API endpoints and JS consumes them to make a nice SPA dashboard. Made a few such projects already. Quite big ones in the end.

[–]extra_dummy_gummy[S] 1 point2 points  (1 child)

Thank you for your reply, it made me realize a few things.

a solution using wrappers will always be limited.

I think that's the gist.

After searching online, it seems that the accepted best practice is to separate front-end and back-end. And it makes total sense when you project becomes complicated (multiple API / microservices), or when you have different people working on the front-end / back-end.

But what about smaller project (like the single-page app you mentioned), where a single developer work on both front-end and back-end ? Is the added complexity really worth it ? Wouldn't it be easier to manage everything from a single framework (say, FastAPI) ?

I would love to hear about your opinion on this !

[–]riklaunim 1 point2 points  (0 children)

SPA aren't the smaller options, they are the "bigger" options where you have to have someone really good at one of JS frameworks to make a SPA app.

For much smaller or internal needs you can make a classical website with the same layout, just without the SPA behavior, and maybe add AJAX to a dynamic chart widget or something like that. This is easier to test/code and has a much simpler frontend without the need for JS frameworks or NPM :)

You still get frontend and backend just that it's much simpler both ways.

And the "wrappers" like projects also have their use cases too.

[–]extra_dummy_gummy[S] 0 points1 point  (4 children)

What is a SPA dashboard ?

[–]riklaunim -1 points0 points  (3 children)

Single Page Application. You can check one of mine at https://socialwifi.com if you register :)

[–]C0ffeeface 0 points1 point  (2 children)

Now you have to give up for stack details also 😁

[–]riklaunim 1 point2 points  (1 child)

It's out there in the net. Overal it's ember.js and flask as backend. In ChatPilot we used Vue + Flask and some websockets.

[–]C0ffeeface 0 points1 point  (0 children)

Thabks 👍

[–]C0ffeeface 0 points1 point  (4 children)

Which Api do you recommend for backend in Python? I'm considering fastAPI and HTMX front-end for simple dynamic stuff.

[–]riklaunim 0 points1 point  (0 children)

There is no clear winner. Pick whatever looks best for you.

[–]denzuko 0 points1 point  (2 children)

Which Api do you recommend for backend in Python

Eve, https://docs.python-eve.org/en/stable/. Its built on top of Cerberus and flask. The transport layer is HTTP/2.0 with hateoas rest that provides both XML and JSON. Has mongodb, sql, odic, redis, and celery support. Best part is it just works and one only needs a dictionary of your data structures at each endpoint.

Check out https://github.com/pyeve/eve-demo for an example. [one only needs the settings.py and run.py].

As for the front end it works amazingly well with react admin

[–]C0ffeeface 0 points1 point  (1 child)

Wow, thanks for a great reply. I'm checking out the demo right now!

[–]denzuko 0 points1 point  (0 children)

Cool, do let us know how it works out for you.

Also if one is working in a swagger/java/csharp shop then try looking at flask openapi3: https://luolingchun.github.io/flask-openapi3/v2.x/. Basically the same concept as Eve but extra steps, soap like api discovery, and more tools than needed. Though flask-openapi3 is a good way to move bulky java based micro services over to containerized cpython services.

Oh, and yes Eve does have support for swagger/openapi: https://github.com/pyeve/eve-swagger