5 ms·
Ask HN: Are you happy you chose FastAPI over Flask/Django/Sanic/etc.?
- andenacitelli 3y agoA little concerned about FastAPI’s low bus factor, and the docs being only example-driven rather than reference docs gets occasionally annoying, but other than that it’s been nice and we aren’t regretting running it in prod.
- shoo 3y agoIt's hard to distinguish signal from noise in responses to these posts without knowing context of how long people have used fastapi in their system, was it used in production vs a hobby project, what interesting limitations or failure modes did they learn after going into production. I've used fastapi for less than one month, to bash out an API for a simple service, in a commercial environment that doesn't have high load requirements or value software quality. What i like: auto generated API docs, declaring types (not as good as language with static type system, but OK for python ), automatic validation of request/response payloads. What i'm skeptical of: fastapi forces me to use asyncio but my service doesn't have a problem where asyncio helps, fastapi's bespoke dependency injection system -- started to immediately feel awkward when i wanted to write some custom middleware, fastapi encourages you to structure apps with a bunch of global state & then write tests by monkey-patching that global state in test harnesses (more a style mismatch, not a blocking problem). What's actually been a serious problem: haven't been using it long enough in production to have an opinion. We used Python as we had a bunch of existing business logic in Python we wanted to re-use, we're prioritizing "can it exist and be integrated very quickly" over other concerns such as scalability or long term maintenance costs or software supply chain concerns. If we were starting from a clean slate with no Python code, Python + FastAPI isn't obviously a superior choice to go + go standard http library + chi router.
- ps256 3y agoYes, FastAPI is great for APIs. Django is still more feature rich for actual websites. I don't see a reason to pick Flask for a new project in 2023.
- extasia 3y agoAgreed, flask is nice for a student who wants to handroll a lot of code as a learning experience, but you end up reinventing the wheel unnecessarily IME. The library ecosystem for flask seems quite fractured which doesn't help.
- nextworddev 3y agoWhat are the best ways to deploy fastapi products for production?
- andrewfromx 3y agoabsolutely. And you can just add: from fastapi.templating import Jinja2Templates if you want to render html.
- VoodooJuJu 3y agoYes, though I prefer Starlette, which is FastAPI without the bloat and shilling.
- ps256 3y agoBuilt-in Pydantic validation is nice, I wouldn't call it bloat.