The main requirements for this course are:
If you aren't familiar with the command-line, programming text editors, UNIX, and/or don't have a good comfort level with basic usage of Python/Git already, then you can take the "beginner track" in this course.
Rather than setting up your local computer, you will simply follow along what I'm doing on the screen, and optionally connect to a server I have set up where you can experiment with an IPython Notebook and CodeMirror HTML Editor.
You can download the code to follow along:
http://pixelmonkey.org/pub/rapid-web-code.zip
Some good background reading for this course is the presenter's blog post, "Build a web app fast: Python, HTML & JavaScript resources".
You'll likely have the pre-reqs, but let's make sure you have some good versions. Open a terminal.
Run python -V
and make sure you're on Python 2.7.x.
Run git --version
to make sure you have git 1.7/1.8 installed.
A recent Python version (2.7.3) can be installed from http://python.org.
A recent Git version (1.8.1) can be downloaded from http://git-scm.com.
This course assumes you can walk around the command line a bit.
A quick cheat sheet:
ls
: list files in current directorypwd
: print working directory pathcd <path>
: change directorymkdir <path>
: create a directorycat <file>
: show contents of filenano <file>
: open file in nano text editorMake a work area::
mkdir ~/repos
Clone the code respository::
git clone git://github.com/amontalenti/rapid-web.git
cd rapid-web
Inspect the tags::
git tag -l
Look at Github web interface:
https://github.com/amontalenti/rapid-web/
Feel free to fork!
All the changes from the initial check-in to the last on Github.
https://github.com/amontalenti/rapid-web/compare/v0.2-static...v2.0-fin
easy_install
command may not be available in some borked Python versions on
Linux and OS X.
Try easy_install --version
to check.
If not available, use this script::
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
Run this virtualenv setup::
$ sudo easy_install pip
$ sudo pip install virtualenv
Then::
$ cd rapid-web
$ virtualenv rapid-env
This will create a self-contained Python installation for use with this tutorial.
One of the first Python development tools I'll use in hour 2 is IPython.
It lets us test code at the command-line easily.
Prototyping code at the command-line is one of the core ways to do effective prototyping beyond the HTML / CSS / JavaScript phase.
You should now have a virtualenv folder called rapid-env
. For convenience,
let's make it easy to activate::
$ ln -s rapid-env/bin/activate
Activate it with the "magic incantation"::
$ source activate
And then, install IPython::
(rapid-env)$ pip install ipython
... lots of output ...
(rapid-env)$ ipython -V
0.13.1
$ cat requirements.txt
ipython
Flask
$ pip install -r requirements.txt
...
Then, confirm that you can import all the libraries.
$ ipython
>>> import flask
>>> import jinja2
>>> import werkzeug
>>> <CTRL+D>
Do you really want to exit ([y]/n)? y
$
If you install some optional requirements, you can get:
$ cat dev-requirements.txt
# for live code updates
livereload
# for ipython notebook
tornado
pyzmq
$ pip install -r dev-requirements.txt
...
$ ipython notebook
<CTRL+C to quit>
$ livereload -p 8000
<CTRL+C to quit>
To actually use LiveReload, you need a browser extension for chrome which can be downloaded here:
https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei
We're going to ssh into a remote server in the final hour of the course for deployment.
To do this, we're going to need to add your public key to the server's list of "authorized keys".
If you are already a Github user or remotely manage servers with SSH, then you probably don't need to generate a new public key, but I've included these instructions here for those of you who don't already have public keys.
Try::
cat ~/.ssh/id_*.pub
Do you get output like::
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQE...
If so, you do already have a public key.
SSH has a small configuration file at ~/.ssh/config
that allows you to
specify hostnames that ssh will use.
Upon connecting to a server, ssh looks for an identity file for public key
authentication. This is typically ~/.ssh/id_rsa
.
This private key has a matching public key, which is typically ~/.ssh/id_rsa.pub
and must be listed in the remote host's ~/.ssh/authorized_keys
file.
ssh-keygen
can create the public/private key for you. Then you need to
share the public key with me.
At the terminal::
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user1/.ssh/id_rsa):
Your identification has been saved in /home/user1/.ssh/id_rsa.
Your public key has been saved in /home/user1/.ssh/id_rsa.pub.
The key fingerprint is:
43:55:f0:cc:1a:9f:ff:2e:3a:a8:94:8c:f1:62:d3:b1 user1@hacknode
...
Edit the file::
$ nano ~/.ssh/config
And insert contents::
Host hacknode
User shared
HostName hacknode.alephpoint.com
Then::
$ ssh hacknode
It'll prompt you for a password right now, but that's OK -- just CTRL+C to abort.
To get access to the server, submit your public key via this Google Form:
https://docs.google.com/forms/d/1RI13bmppgmFAzgtDOJwaNx_QfGV2_I5Thnc3UhXS4pg/viewform
There are pretty straightforward instructions for every operating system at:
But I have also pre-installed it on our hacknode
server to save us some time, if you don't want to load up your machine with it.
The slides will be web-based and downloadable. You can find information about them here:
https://github.com/amontalenti/rapid-web-slides/blob/master/README.md
Contact the instructor directly at pixelmonkey@pixelmonkey.org.