Web = Backend and Frontend
Python and web so far means only backend. Python needs more technologies in the front side to build webs: Javascript, Backbone, AngularJS, React...
Python and backend
On top of libraries and utilities
A Web framework is a set of utilities with inner consistency which provide a simple way to solve common issues in web development: authentication, ddbb access, template rendering, request and response management, sessions...
A web framework is the tool and the opinion and good practices around
Business on top of a framework
http://bottlepy.org/docs/dev/index.html
Is: a microframework whose potential resides in fast prototyping and small websites
Is not: the tool for big applications
Has: Routing, Templates, Utilities (forms, file uploads, cookies, headers...), Server (wsgi)
Who: me!
Hello world
from bottle import route, run, template
@route("/hello/")
def index(name):
return template("Hello {{name}}!", name=name)
run(host="localhost", port=8080)
http://localhost:8080/hello/world
http://flask.pocoo.org/
Is: a microframework running over Werkzeug, with Jinja templates "and good intentions".
Is not: full of features out of the box
Has: built in development server and debugger, unit testing support, RESTful, Jinja2 templating, support for secure cookies, 100% WSGI 1.0 compliant, extensively documented
Who: http://flask.pocoo.org/community/poweredby/ (Dominion clone!!)
Hello world
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
http://localhost:5000/
http://www.pylonsproject.org/
Is: component ecosystem, with Pyramid as web framework. Small core unopinionated.
Is not: as mature as Django although it competes with Django
Has: fast prototyping, decorators based configuration, routing, debugger, add-ons...
Who: http://www.quora.com/Who-uses-the-Pyramid-framework-for-web-applications-And-how HOT-OSM, Reddit, Mozilla
Hello world
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello %(name)s!' % request.matchdict)
if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/hello/{name}')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
http://localhost:8080/
https://www.djangoproject.com/
Is: the reference tool for web development with Python
Is not: free of strong opinion; famous for front integration
Has: everything, built-in or libraries (DRF), community!!
Who: Taiga, Guía Repsol, Disqus, Pinterest... (http://codecondo.com/popular-websites-django/)
Anillo (https://github.com/jespino/anillo)