3 ms·
I too recently started using Starlette for https://sqwok.im https://sqwok.im and had investigated FastAPI & Responder. Both look promising but I've found that
by holler 6y ago
I too recently started using Starlette for https://sqwok.im https://sqwok.im and had investigated FastAPI & Responder.
Both look promising but I've found that Starlette on it's own is very lightweight, well-designed, and straightforward to work with (coming from many years of flask/django).
Some nice features of FastAPI are the automatic response type handling, e.g. "return {'json': 'yes'}" vs "return JSONResponse({})", and the flask-like route decorators. I ended up building the former manually into my project.
Both Starlette and FastAPI are worth checking out, especially if you've spent time building python web apis with django or flask in the past.
- ytjohn 6y agoI may have done something wrong, but I remember that when I would do 'return {"json": "yes"}', it would not set the content-type to json. When I discovered this, I had to go back through a bunch of code and convert it to either fastaspi.Response or JSONResponse. Creating the Response instance proved to be a better approach, because it makes it much easier to set content type, status codes, cookies, headers, etc. Again - I might have done something wrong, but if you have an instance just doing 'return {"key": "value"}', check it with curl or browser dev tools to see what the Content-Type is.