Webscraping with Python. Flask-pycon-2011. Frictionless Web Development with Flask. Feb 03, 2011 Static Sites and Rapid Iteration with a Lightweight Python Kit of Flask, YAML, Markdown and Fabric.
For a while I've been looking for a more fluid toolkit for rapidly developing and iterating static sites. I have three use cases in mind: client html mockups with rapid iterations or slight variations, maintaining the static client sites that I have in the stable, and hacking on my own site. In each of these cases, dealing with databases, CMSs, versioning, or directories of HTML files was either too heavy, too slow, or both. My goals are straightforward: First, A Diversion Web development can become a chore, with too little time actually creating things and too much time learning APIs, stitching them together, and trying to remember their syntax. when I'm making a Django site, I feel like I'm programming in Django instead of Python.
Flask, As Simple As You Want To Be Flask is a relatively new project that is part of the nice growing collection of packages under the Pocoo banner. DENIED. WebFrameworks. A Web framework is a collection of packages or modules which allow developers to write Web applications (see WebApplications) or services without having to handle such low-level details as protocols, sockets or process/thread management.
The majority of Web frameworks are exclusively server-side technology, although, with the increased prevalence of AJAX, some Web frameworks are beginning to include AJAX code that helps developers with the particularly tricky task of programming (client-side) the user's browser. At the extreme end of the client-side Web Frameworks is technology that can use the web browser as a full-blown application execution environment (a la gmail for example): see Web Browser Programming for details. Generally, frameworks provide support for a number of activities such as interpreting requests (getting form parameters, handling cookies and sessions), producing responses (presenting data as HTML or in other formats), storing data persistently, and so on.
Web Services in Python (Part 2) - Serving Static Files. The last Python web server wasn't that great - it only gives you a hello world.
If you're smart, you may have already figured out how to do Comet with it with very little code - we'll go over that in the next post. But.. the server doesn't even serve JavaScript files yet! Well, don't panic. In the land of Python, everything is just a few lines of code away. I'll assume you already have the systems libraries from my last blog post installed from this point on. . # apt-get install libevent-2.0 libevent-dev python-dev python-virtualenv So that's 1 line of code to set up the environment - if you haven't done it already. Next, we'll setup the sandbox for the web server - it's not absolutely needed but it's good practice to sandbox web applications with virtualenv in Python. . $ virtualenv myapp $ cd myapp $ . bin/activate 3 lines of code to initialize and enter the virtualenv sandbox - not absolutely required, but good for library hygiene. Next, we'll install a few things to our sandbox.
Look Ma! Web Services in Python (Part 1) - You Only Need 3 Lines Of Python Code. I cringe whenever I see someone meddling with Apache or nginx config files to do something simple these days.
And worse - the usual LAMP stack is terrible at handling anything that's actually asynchronous in nature, like WebSocket or Comet. It can also be a pretty big security hole as well, see Slowloris. And yet, you have to read lengthy manuals and fiddle with lengthy config files to get anything done with the traditional web servers - instead of getting shit done, like, right now. Seriously, this is 2011. You're doing more for less if you're sticking to the 2000 ways.
Let's try another way. So, let's say you have a usual Ubuntu, or Debian, or the more trendy Mint machine. . $ sudo apt-get install libevent-2.0 libevent-dev python-dev python-virtualenv $ virtualenv webservice $ . webservice/bin/activate $ pip install gevent gunicorn.