News for hackers. Stuff that matters.
Re:FastAPI framework, high perf, easy to learn, fast to code... by iooi on Monday February 01, 2021 @01:00PM (#25991267)
I would love to know what HN's python folks are using for new projects these days.

I've looked at FastAPI before and it has some nice features like asyncio and pydantic integrations. But it doesn't have any official users library, and ideally a framework should have that available.

I've started looking outside of the Python ecosystem since it feels like there's nothing new and exciting come out of there. I've played around a bit with NestJS and it's amazing how far the TypeScript ecosystem has come.

It's also crazy that SQLAlchemy doesn't have typing support still, so TypeORM looks really appealing.

Re:FastAPI framework, high perf, easy to learn, fast to code... by alchermd on Monday February 01, 2021 @01:45PM (#25991896)
I still use Django to this day, both for monolithic SSRs and REST APIs. All the batteries it comes with are perfect for the common use case, and the small "bubble" around it (ex: DRF) is as good as it gets IMO.

The tooling around REST APIs are lacking compared to Flask and FastAPI, but wrangling what's available (drf-yasg, oauth2lib) to suit my needs is better than migrating to another framework I think.

Re:FastAPI framework, high perf, easy to learn, fast to code... by konschubert on Monday February 01, 2021 @02:37PM (#25992678)
Same here. When I want to get a new project of the ground, I use Django.

This partially due to the batteries included, partially because I am very familiar with it.

On more mature projects, at the stage where I really start splitting services into their own hosts, I switch to something else. Django's batteries are no longer useful at this stage, since e.g. auth is it's own service now.

Re:FastAPI framework, high perf, easy to learn, fast to code... by tiangolo on Monday February 01, 2021 @02:32PM (#25992617)
I also looked at NestJS before creating FastAPI, and it certainly inspired ideas in FastAPI (also TypeScript in general), you can read more about that here: https://fastapi.tiangolo.com/alternatives/

About ORM with types, yeah, I also want an ORM based on standard type annotations. So I started playing with mixing SQLAlchemy and Pydantic, and I have some unfinished lab experiment with it.

I haven't found the time to finish it, but hopefully I'll find it soon.

Re:FastAPI framework, high perf, easy to learn, fast to code... by nickjj on Monday February 01, 2021 @04:31PM (#25994257)
I still happily use Flask with mostly Jinja rendered templates.

With things like Hotwire and htmx you can build very nice feeling apps without going all-in with an API back-end and JS front-end.

I released https://github.com/nickjj/docker-flask-example as a starter kit for what I use in new projects. It wires up things like SQLAlchemy, Celery, Flask, gunicorn, Webpack, etc. with Docker. It also comes with CLI extensions for digesting / md5 tagging assets with optional CDN support using Flask-Static-Digest, database migrations / seeding with Flask-DB and more.

If I ever need to create API endpoints I combine Flask-Classful (routing), Marshmallow (serialization / validation) and Flask-JWT-Extended (authentication). I've written about this combo at: https://nickjanetakis.com/blog/flask-libraries-for-building-...

Re:FastAPI framework, high perf, easy to learn, fast to code... by gmfawcett on Monday February 01, 2021 @01:05PM (#25991333)
I disagree that FastAPI should have an official users library. A popular third-party one would be fine, but it doesn't belong in the core project.
Re:FastAPI framework, high perf, easy to learn, fast to code... by iooi on Monday February 01, 2021 @01:24PM (#25991589)
I can see that, I think what I meant was "de facto" (think flask-user) library instead of "official".
Re:FastAPI framework, high perf, easy to learn, fast to code... by __mp on Monday February 01, 2021 @02:16PM (#25992397)
We're using FastAPI for the backend. We then use the OpenAPI.json exposed by the documentation endpoint to generate API bindings for Typescript.
Re:FastAPI framework, high perf, easy to learn, fast to code... by eddsalkield on Monday February 01, 2021 @01:37PM (#25991781)
I'd recommend you check out FastAPI-Users if you haven't already: https://github.com/frankie567/fastapi-users

It provides a users framework with OAuth2 integration, support for different ORM backends, and routes for authentication, verification, etc.

Full disclosure: I am a contributor to this project.

Re:FastAPI framework, high perf, easy to learn, fast to code... by boxed on Monday February 01, 2021 @01:53PM (#25992024)
Django plus django-fastdev plus iommi.

Full disclosure: I'm the author of django-fastdev and co-author of iommi.