We need to write a lot of small APIs in Python for SPAs. We ended up going with FastAPI which utilizes Starlette under the hood. I'm surprised neither of them are mentioned here. Starlette was developed by the same dev who wrote the Django RESTful package. If you mostly just need REST APIs or even GraphQL, it feels far more light and modern than anything in Django and forms some better opinions around things than the…
Do frameworks need to be asynchronous or is it good enough to just spawn threads for background tasks?
A Beginner’s Introduction to Python Web Frameworks (2018)
31–40 of 168 posts
Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#32Earlier quoted context omitted.
Why, a Docker container. Yes, even on Windows. Pack up everything into a single image, downloadable from nearly anywhere. Your web server (which likely also terminates TLS) has to have fastcgi support, you configure the fastcgi and database ports, maybe mount a directory with config files into the container, and that's it.
>Yes, even on Windows. This would require you to run your containers on Windows servers right? Not much reason to do that anymore. Instead should just containerize as part of deployment pipeline
Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#33Earlier quoted context omitted.
It's also a myth that Django makes it difficult to pick and choose. For example, this article fails to mention that Django includes support for alternative template engines, including the popular Jinja2. Of course, if you choose not to use a feature like the ORM, you won't get any of the benefits of that feature- but Django doesn't get in your way or make it difficult in any way to do so. You can use as many differen…
Everything you wrote is true, however I think using another ORM in Django is asking for trouble, or at least it's missing a lot of the benefit of Django. The way models work with admin, forms, etc is to me what makes Django so efficient. Also, you don't get much by switching Django templates to Jinja.
It made sense because it was database-heavy and UI-light.
Yes, you have to do a bit more when producing forms. You have to do it anyway if your DB operations are not simple CRUD.
Sure you lose much of admin stuff, too.
Django is a framework, a structure where you add (preferably small) pieces of your code to customize its behavior. If what you are building deviates seriously from what the framework was intended for, it quickly becomes more of nuisance than help. But within its subject area, a framework is highly efficient.
Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#34For such a comprehensive list, no mention of tornado?
I use Tornado to serve the WebSocket backend for https://www.slickdns.com/live/. I've also used Django Channels to add WebSocket support to a Django app and found it very cumbersome compared to Tornado.
Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#35Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#36Earlier quoted context omitted.
Thanks for pointing to Starlette, I didn't know it and it looks interesting. I completely agree with you on Django. I've had the chance to implement an e-commerce solution in Flask and another one in Django and the process has been a lot easier and faster with Django. You just can't beat having all the basic tools bundled and configured, along with one central documentation.
Just curious, what are you using as a payments solution for an e-commerce site in Django? I've yet to find a solid implementation for that, though I guess diving into Saleor and picking out parts of that implementation is the best choice?
Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#37Earlier quoted context omitted.
Do frameworks need to be asynchronous or is it good enough to just spawn threads for background tasks?
async is more beneficial for when code is primarily network bound. WSGI is thread based which comes with a higher overhead for task switching. So it’s just not as efficient for most web server tasks.
Would you use this async then in instances where some of the API calls don't matter to your user?
Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#38I was forced to encounter Web2Py in an open-source project several years ago. It was awful. Besides the fact that it's stuck in Python 2 (seriously, even today?), it had a lot of bizarre design decisions. For instance, it loaded controllers by concatenating files in a directory - alphabetically. I know Python's import system can confuse some folks, but surely there was a better way. The whole thing left a very sour t…
Developer has a new effort underway that is a little more "pythonic": https://github.com/web2py/py4web
Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#39I was forced to encounter Web2Py in an open-source project several years ago. It was awful. Besides the fact that it's stuck in Python 2 (seriously, even today?), it had a lot of bizarre design decisions. For instance, it loaded controllers by concatenating files in a directory - alphabetically. I know Python's import system can confuse some folks, but surely there was a better way. The whole thing left a very sour t…
I have used it for largish projects, and consider it very much not awful at all, but I am aware of opinions on the subject often being polarised (Flask creator Armin Ronacher for one has spent a lot of words and energy badmouthing Web2Py - a behaviour I personally find somewhat unbecoming).
For those not caught up in dogma too much: Try it. Got a lot going for it, and the docs are superb.
Re: A Beginner’s Introduction to Python Web Frameworks (2018)
#40 New kids on the block:
- Starlette https://www.starlette.io
- Vibora https://vibora.io
- Xweb https://github.com/gaojiuli/xweb
- Storm https://github.com/jiajunhuang/storm
- Responder http://python-responder.org
- Quart https://pgjones.gitlab.io/quart/
- Sanic https://sanic.readthedocs.io
- Bocadillo https://bocadilloproject.github.io/
- Japronto https://github.com/squeaky-pl/japronto
The old guard:
- Flask http://flask.pocoo.org
- Tornado http://www.tornadoweb.org
- Falcon https://falconframework.org/
- Bottle https://bottlepy.org
- Pyramid https://trypyramid.com/
- CherryPy https://cherrypy.org/
Less known older ones:
- Wheezy Web https://pythonhosted.org/wheezy.web/
- API Hour https://pythonhosted.org/api_hour/
- Morepath https://morepath.readthedocs.io/en/latest/toc.html
- Klein https://github.com/twisted/klein
- Weppy http://weppy.org/