Ask HN: Best Python web framework
31–40 of 110 posts
Re: Ask HN: Best Python web framework
#32I really like bottle.py [1]. I've used it for a couple of different projects; although not fundamentally different from web.py or flask, it seems to just "make sense". [1] http://bottlepy.org/docs/stable/ An example from their website: from bottle import get, post, request @get('/login') # or @route('/login') def login_form(): return ''' ''' @post('/login') # or @route('/login', method='POST') def login_submit(): nam…
from flask import Flask, request
app = Flask(__name__)
@app.route('/login')
def login_form():
return '''
'''
@app.route('/login', methods=['POST'])
def login_submit():
name = request.form.get('name')
password = request.form.get('password')
if check_login(name, password):
return "Your login was correct
"
else:
return "Login failed
"Re: Ask HN: Best Python web framework
#33CherryPy has had Python 3 support for quite a while now. Not many Python frameworks have that. Pylons just got it, so I'd go with CherryPy. You can get WebSocket support too, and documentation is OK.
Re: Ask HN: Best Python web framework
#34(Full disclosure: I'm a member of Django's core team) There's no single "best" for every application. One-size-fits-none. One of Django's strengths is in the fact that parts of the framework come off easily when they no longer serve your needs. If the ORM is no longer working for you, you can use SQLAlchemy or write raw SQL. Authentication no longer working for you? Write your own or use a 3rd party one. Et cetera. T…
I would simplify further: Are you building an API? If yes, use Flask. Are you building a website? If yes, use Django. Are you building an API and a website? If yes, use Flask for the API and consume it from a Django site. I wouldn't advocate using Django but ditching the ORM for SQLAlchemy, nor replacing the Auth, as noted (above or below my comment) it gets messy and becomes a lonely road fast. I would advocate movi…
I'd also argue in favour of ditching Django's auth. It's fine if your project has very simple auth requirements, but these days very few interesting projects have simple auth requirements - plus it's much easier to extend the functionality of your own Account models than to try and hook extra stuff on to Django's.
Re: Ask HN: Best Python web framework
#35(Full disclosure: I'm a member of Django's core team) There's no single "best" for every application. One-size-fits-none. One of Django's strengths is in the fact that parts of the framework come off easily when they no longer serve your needs. If the ORM is no longer working for you, you can use SQLAlchemy or write raw SQL. Authentication no longer working for you? Write your own or use a 3rd party one. Et cetera. T…
> One of Django's strengths is in the fact that parts of the framework come off easily when they no longer serve your needs. If the ORM is no longer working for you, you can use SQLAlchemy. Authentication no longer working for you? Write your own or use a 3rd party one. Yes and no (disclaimer: I mostly use Django for my development), while parts come off easily the tools provided by the framework are "standard" and t…
Re: Ask HN: Best Python web framework
#36(Full disclosure: I'm a member of Django's core team) There's no single "best" for every application. One-size-fits-none. One of Django's strengths is in the fact that parts of the framework come off easily when they no longer serve your needs. If the ORM is no longer working for you, you can use SQLAlchemy or write raw SQL. Authentication no longer working for you? Write your own or use a 3rd party one. Et cetera. T…
I would simplify further: Are you building an API? If yes, use Flask. Are you building a website? If yes, use Django. Are you building an API and a website? If yes, use Flask for the API and consume it from a Django site. I wouldn't advocate using Django but ditching the ORM for SQLAlchemy, nor replacing the Auth, as noted (above or below my comment) it gets messy and becomes a lonely road fast. I would advocate movi…
Implementation-wise they both hook into the model framework and the form framework, although you can swap out those parts if your data lives elsewhere.
Re: Ask HN: Best Python web framework
#37http://en.wikipedia.org/wiki/Pyramid_%28web_framework%29
* faster.
* better quality (100% statement coverage via unit tests)
* supports latest python.
* great documentation (including free up to date book). There's also a separate pyramid cookbook.
* simplicity. If you just see a pyramid app, you can dive right in fairly easily without learning lots of alien stuff.
* sensible defaults, and you can choose to swap out parts easily if you want (templates, ORM, etc).
* works well with other python software, doesn't bundle everything in, with NIH syndrome.
* great tools. like the web console that drops straight into a debugger when an exception happens on the page you're looking at.
The framework that starts with D is a legacy framework (doesn't even support python3 yet).
Re: Ask HN: Best Python web framework
#38The best for what? What do you want to do? We have found Django to be great for throwing up a site quickly. We primarily use Pyramid now for our more serious development as it fits more with what we're trying to achieve. My feeling is the beauty of Python is that there are more than one ways of doing something. Define what you want out of your framework, try some and then see how you feel
The specific project I'm looking at is a small photo-sharing app for a newspaper website. Functionally simple, but with some pretty intense traffic spikes. Since it's a straightforward job I'd like to use it as an opportunity to switch to Python, which I've been itching to do for a while (alternative would be Symfony on PHP). However I have a longer term concern, which is that I don't want to be learning a new framew…
A small photo sharing app that deals with occasional intense traffic spikes sits bang in the middle of Django's sweet spot (I'd suggest investigating the Django cache_page decorator, or maybe looking at integrating with Varnish).
Re: Ask HN: Best Python web framework
#39I use web2py. It struggles to get the attention that Django gets, but it has a robust development community. It offers a good balance between Django (which i find a little big and unwieldy), and Flask (which I think suffers from the opposite problem).
What's the opposite problem?
Flask is designed under the assumption that you will most likely use third party frameworks for stuff like database abstraction and input validation.
It's kinda neat in that regard, and if you prefer to work that way then more power to you.
But I believe Web2py gets the balance between 'batteries included' and 'find your own damn batteries' right.
Re: Ask HN: Best Python web framework
#40CherryPy has had Python 3 support for quite a while now. Not many Python frameworks have that. Pylons just got it, so I'd go with CherryPy. You can get WebSocket support too, and documentation is OK.
Yep, cherrypy is my tool of choice also, very simple , very light , does the job. I have used tornado, which i quite like also ...