layout | title |
---|---|
ots |
Coach Guide |
Thanks for coaching! Check out the generic OpenTechSchool coaching guide as well!
We are recommending Python 3.3 for this workshop, though they can use Python 2.7 if they wish. Python 3 versions older than 3.3 are not supported by Flask.
With Python installed, we then recommend using distribute's easy_install
to install pip, then using pip to install virtualenv.
Then with virtualenv they can create an isolated installation of Python inside their working directory for the workshop. Once they have run the virtualenv activate script then when they run pip install flask
it will install Flask to their working directory instead of the system Python.
This workshop is concerned with building a simple website with Python Flask. There are two parts:
- A home page containing a form for submitting an email address.
- A page for listing the submitted emails.
A Flask app is just a single Python file with a function for each URL in the web app. It has a simple template system and we just use an in-memory list to store the email addresses.
See it running on Heroku: Here is the home page where people can enter their email address and the emails page where you can view the list of submitted emails.
You can see the source code for the final example here.
Finally, the Flask Documentation is quite comprehensive and covers a lot of topics about building a website. The reason we chose Flask (over Bottle et al) is that the documentation is very good. So we encourage you to send people there!
Participants will likely have questions about HTML and CSS. We have some links in the extras section for learning more which you can direct them to. There is also the 'Professional CSS' section if they are interested in hardcore stuff like Twitter Bootstrap, SASS and LESS.
For this workshop the focus is on what the website can do, not what the website looks like. So perhaps try to ask people what things they want their sites to do rather than how they look.
Windows can be a little annoying to set up. Because people will probably end up with multiple installations of Python I wouldn't recommend setting up PATH. Instead, just use the full path to python.exe
and scripts. It only needs to be done to get virtualenv. Once they have activated a virtualenv environment then they will not need to use full paths.