|
|
@ -9,10 +9,10 @@ way and why there are multiple ways. |
|
|
|
|
|
|
|
|
|
|
|
Flask depends on two external libraries: `Werkzeug |
|
|
|
Flask depends on two external libraries: `Werkzeug |
|
|
|
<http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_. |
|
|
|
<http://werkzeug.pocoo.org/>`_ and `Jinja2 <http://jinja.pocoo.org/2/>`_. |
|
|
|
The first one is responsible for interfacing WSGI the latter for rendering |
|
|
|
The first on is responsible for interfacing WSGI the latter to render |
|
|
|
templates. Now you are maybe asking, what is WSGI? WSGI is a standard |
|
|
|
templates. Now you are maybe asking, what is WSGI? WSGI is a standard |
|
|
|
in Python that is basically responsible for ensuring that your application |
|
|
|
in Python that is basically responsible for ensuring that your application |
|
|
|
is behaving in a specific way so that you can run it on different |
|
|
|
is behaving in a specific way that you can run it on different |
|
|
|
environments (for example on a local development server, on an Apache2, on |
|
|
|
environments (for example on a local development server, on an Apache2, on |
|
|
|
lighttpd, on Google's App Engine or whatever you have in mind). |
|
|
|
lighttpd, on Google's App Engine or whatever you have in mind). |
|
|
|
|
|
|
|
|
|
|
@ -26,10 +26,10 @@ Virtualenv is what you want to use during development and in production if |
|
|
|
you have shell access. So first: what does virtualenv do? If you are |
|
|
|
you have shell access. So first: what does virtualenv do? If you are |
|
|
|
like me and you like Python, chances are you want to use it for another |
|
|
|
like me and you like Python, chances are you want to use it for another |
|
|
|
project as well. Now the more projects you have, the more likely it is |
|
|
|
project as well. Now the more projects you have, the more likely it is |
|
|
|
that you will be working with different versions of Python itself or at |
|
|
|
that you will be working with different versions of Python itself or a |
|
|
|
least an individual library. Because let's face it: quite often libraries |
|
|
|
library involved. Because let's face it: quite often libraries break |
|
|
|
break backwards compatibility and it's unlikely that your application will |
|
|
|
backwards compatibility and it's unlikely that your application will |
|
|
|
not have any dependencies, that just won't happen. So virtualenv to the |
|
|
|
not have any dependencies, that just won't happen. So virtualenv for the |
|
|
|
rescue! |
|
|
|
rescue! |
|
|
|
|
|
|
|
|
|
|
|
It basically makes it possible to have multiple side-by-side |
|
|
|
It basically makes it possible to have multiple side-by-side |
|
|
@ -47,7 +47,7 @@ or even better:: |
|
|
|
|
|
|
|
|
|
|
|
$ sudo pip install virtualenv |
|
|
|
$ sudo pip install virtualenv |
|
|
|
|
|
|
|
|
|
|
|
Chances are you have virtualenv installed on your system then. Maybe it's |
|
|
|
Changes are you have virtualenv installed on your system then. Maybe it's |
|
|
|
even in your package manager (on ubuntu try ``sudo apt-get install |
|
|
|
even in your package manager (on ubuntu try ``sudo apt-get install |
|
|
|
python-virtualenv``). |
|
|
|
python-virtualenv``). |
|
|
|
|
|
|
|
|
|
|
@ -69,11 +69,7 @@ within:: |
|
|
|
Now you only have to activate it, whenever you work with it. On OS X and |
|
|
|
Now you only have to activate it, whenever you work with it. On OS X and |
|
|
|
Linux do the following:: |
|
|
|
Linux do the following:: |
|
|
|
|
|
|
|
|
|
|
|
$ . env/bin/activate |
|
|
|
$ source env/bin/activate |
|
|
|
|
|
|
|
|
|
|
|
(Note the whitespace between the dot and the script name. This means |
|
|
|
|
|
|
|
execute this file in context of the shell. If the dot does not work for |
|
|
|
|
|
|
|
whatever reason in your shell, try substituting it with ``source``) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If you are a Windows user, the following command is for you:: |
|
|
|
If you are a Windows user, the following command is for you:: |
|
|
|
|
|
|
|
|
|
|
@ -101,8 +97,8 @@ This is possible as well, but I would not recommend it. Just run |
|
|
|
(Run it in an Admin shell on Windows systems and without the `sudo`). |
|
|
|
(Run it in an Admin shell on Windows systems and without the `sudo`). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Living on the Edge |
|
|
|
Leaving on the Edge |
|
|
|
------------------ |
|
|
|
------------------- |
|
|
|
|
|
|
|
|
|
|
|
You want to work with the latest version of Flask, there are two ways: you |
|
|
|
You want to work with the latest version of Flask, there are two ways: you |
|
|
|
can either let `easy_install` pull in the development version or tell it |
|
|
|
can either let `easy_install` pull in the development version or tell it |
|
|
@ -115,7 +111,7 @@ Get the git checkout in a new virtualenv and run in develop mode:: |
|
|
|
Initialized empty Git repository in ~/dev/flask/.git/ |
|
|
|
Initialized empty Git repository in ~/dev/flask/.git/ |
|
|
|
$ cd flask |
|
|
|
$ cd flask |
|
|
|
$ virtualenv env |
|
|
|
$ virtualenv env |
|
|
|
$ . env/bin/activate |
|
|
|
$ source env/bin/activate |
|
|
|
New python executable in env/bin/python |
|
|
|
New python executable in env/bin/python |
|
|
|
Installing setuptools............done. |
|
|
|
Installing setuptools............done. |
|
|
|
$ python setup.py develop |
|
|
|
$ python setup.py develop |
|
|
@ -131,7 +127,7 @@ To just get the development version without git, do this instead:: |
|
|
|
$ mkdir flask |
|
|
|
$ mkdir flask |
|
|
|
$ cd flask |
|
|
|
$ cd flask |
|
|
|
$ virtualenv env |
|
|
|
$ virtualenv env |
|
|
|
$ . env/bin/activate |
|
|
|
$ source env/bin/activate |
|
|
|
New python executable in env/bin/python |
|
|
|
New python executable in env/bin/python |
|
|
|
Installing setuptools............done. |
|
|
|
Installing setuptools............done. |
|
|
|
$ easy_install Flask==dev |
|
|
|
$ easy_install Flask==dev |
|
|
@ -152,7 +148,7 @@ Once you have done that it's important to add the `easy_install` command |
|
|
|
and other Python scripts to the path. To do that you have to add the |
|
|
|
and other Python scripts to the path. To do that you have to add the |
|
|
|
Python installation's Script folder to the `PATH` variable. |
|
|
|
Python installation's Script folder to the `PATH` variable. |
|
|
|
|
|
|
|
|
|
|
|
To do that, right-click on your "Computer" desktop icon and click |
|
|
|
To do that, click right on your "Computer" desktop icon and click |
|
|
|
"Properties". On Windows Vista and Windows 7 then click on "Advanced System |
|
|
|
"Properties". On Windows Vista and Windows 7 then click on "Advanced System |
|
|
|
settings", on Windows XP click on the "Advanced" tab instead. Then click |
|
|
|
settings", on Windows XP click on the "Advanced" tab instead. Then click |
|
|
|
on the "Environment variables" button and double click on the "Path" |
|
|
|
on the "Environment variables" button and double click on the "Path" |
|
|
@ -165,7 +161,7 @@ the following value:: |
|
|
|
|
|
|
|
|
|
|
|
;C:\Python26\Scripts |
|
|
|
;C:\Python26\Scripts |
|
|
|
|
|
|
|
|
|
|
|
Then you are done. To check that it worked, open the cmd and execute |
|
|
|
Then you are done. To check if it worked, open the cmd and execute |
|
|
|
"easy_install". If you have UAC enabled it should prompt you for admin |
|
|
|
"easy_install". If you have UAC enabled it should prompt you for admin |
|
|
|
privileges. |
|
|
|
privileges. |
|
|
|
|
|
|
|
|
|
|
|