Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate and provide samples of rendering html output using fastapi endpoints #96

Open
devraj opened this issue Mar 25, 2024 · 0 comments
Assignees

Comments

@devraj
Copy link
Member

devraj commented Mar 25, 2024

Is your feature request related to a problem? Please describe.
I've been increasingly becoming unhappy with the inefficiency that React and the likes bring to web development. I find us building client with increasing complexity, dancing around hooks, contexts, and an forever changing suite of technologies.

With react moving to server components and full stack frameworks like nextjs becoming the way of writing react, it would seem that the days of writing client side applications have come to an end.

I agree with @Rich-Harris's thesis of writing writing #transitionalapps and yes I am on the no Javascript on the server camp.

My thesis is based on:

  • Anomaly's preferred toolchain is based around Python
  • Python libraries and ecosystem is way superior (I really don't understand things like @prisma outside of their service offering where they are looking to geographically scale databases - hence ignoring using strong keys etc, I think without context it's promotes a complete misunderstanding of RDBMS modelling)
  • Python is just generally better to write
  • I am yet to be shown that NextJS and likes are great for application development outside of buying into a hosted service like vercel

Describe the solution you'd like
One of the applications that we needed to put into production was using a NextJS server rendered app as the front end (which was hosted on AWS), I came across a bug that wipes cookies when redirecting if you are using the node server. There's a PR with a fix which has been open since the start of February.

The above had me rebuild an entire application in Django for the sake of making it to production. Further research reveals that this is the case for many others who have done the same where the project was anything other than a website.

As part of this I came across approaches like using htmx with various frameworks where we render HTML via fastapi as the template.

The request thus warrants producing a set of samples where we can use FastAPI to produce HTML output and then use libraries like htmx to add interactivity.

There are ideas in there to render partial HTML and of course JSON APIs to add interactivity.

Describe alternatives you've considered
Before heading down this path, I have:

  • Created a template for a remix application
  • NextJS template with SSR to work with the FastAPI application
  • Attempted to use netlify and vercel where we hosted our front ends

In almost all instances using react it just felt like doing so much extra work to:

  • maintain state on the client side for client only apps
  • where talking back to the REST API and using React SSR, it felt like introducing an extra server for no real reason (specially when not using vercel or the likes to host the application)

One can argue about the benefits on say asset optimisation that nextjs brings but that can be achieved without buying into the entire frontend framework? e.g wagtail has similar features.

Additional context
I have definitely considered projects like svelte and take into account the arguments in Rich's talk about nodejs being the only runtime being supported by providers like Cloudflare etal as edge worker infrastructure.

My points to consider are:

  • For most applications is a edge powered application and overkill and is it worth giving up the Python developer experience?
  • FastUI by the @pydantic team is taking a similar approach to building interfaces (note that it still has React in there)
  • We could move back to using Django for all our applications but I find there's is something about micro-frameworks in the Python world as opposed to monoliths like Django (don't get me wrong in projects where we need things like @wagtail the ecosystem is unbeatable).

See also #90 compliance

Programmers are also human used to have a video where he was interviewing a startup and essentially talking about building a social network and goes "we're letting developers use JavaScript to slow them down, yeah?" Not that Python is perfect but this video sums Javascript up.

@devraj devraj self-assigned this Mar 25, 2024
@devraj devraj changed the title Investigate samples of rendering html endpoints using fastapi Investigate and provide samples of rendering html endpoints using fastapi Mar 25, 2024
@devraj devraj changed the title Investigate and provide samples of rendering html endpoints using fastapi Investigate and provide samples of rendering html output using fastapi endpoints Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant