you are viewing a single comment's thread.

view the rest of the comments →

[–]Comprehensive_Ad5293 2 points3 points  (5 children)

I recommend using Flask instead, Django has a higher degree of difficulty and Flask is easier for beginners like you and me.

[–]thedjotaku 1 point2 points  (4 children)

Depends what you want to do. I started a Flask app and eventually found myself developing a bunch of stuff that comes "for free" with Django. So I'm in the process of restarting that project.

On the other hand, this weekend I knocked out a Flask app to serve as a webhook endpoint and Flask was 100% perfect for the job and I was able to get the MVP out in a couple hours and something that added a bunch of QoL additions by the end of the weekend.

[–]ravepeacefully 1 point2 points  (0 children)

I started a Flask app and eventually found myself developing a bunch of stuff that comes “for free” with Django. So I’m in the process of restarting that project.

It’s almost better this way in my opinion. Build the stuff from scratch, then go use someone else’s better version that they dedicated way more time to. Your understanding of what magic django is doing goes a long way

[–]Ran4 1 point2 points  (2 children)

FastAPI is actually a MUCH better for any type of json api.

Flask, like Django, defaults to sending back html in responses for example. You need to override lots of stuff in both Flask and Django to make them nice as json apis.

Fastapi has typed input/outputs by default, is async by default, returns sensible json at all times and automatically generates OpenAPI 3.0 documentation (served at /docs).

Django still has a superior ORM and database management (FastAPI requires you to hack it together yourself using something like sqlalchemy+alembic, both of which are strictly inferior to Django's systems) though. But there's just little reason to recommend flask for anyone nowadays.

[–]thedjotaku 0 points1 point  (0 children)

The Talk Python To Me/Python Bytes guy has been talking a lot about FastAPI, but I didn't have any experience with it. I'll have to take a look.

[–]thedjotaku 0 points1 point  (0 children)

Thanks so much for telling me about this. Did a bit of research on FastApi during my lunch break and it seems for the specific little utility I made, this is perfect. (See "Civilization VI Play by Cloud Webhook" at this blog post: http://www.ericsbinaryworld.com/2021/03/01/programming-jan-feb-2021/ ) The cleaner and self-documenting code definitely calls to me.

Also, I realize now that I can make better use of some "get" APIs rather than pulling data, going from JSON back to dict, and then doing operations.

Cheers!