Airy: Sample app
Published:
This is a short post, I wanted to show how to start an Airy project, and add a sample application.
Small intro to Airy, it’s a stack of frameworks and technologies for rapid web development. We’ve started it because there are times when we need some project up and running in less than a day. It uses Tornado web server, Tornadio2 for websockets implementation, mongoDB as a backend, and jQuery and Twitter Bootstrap for the frontend.
One more thing, by default Airy creates only one connection once user opens the url, and then passes all the information and rendered layouts via websockets. This allows creating async live applications, quite handy in web 2.0 world. So, let’s start.
You’ll need nix environment (Mac will work too), mongoDB, Python 2.7+, Virtualenv.
I’ll use ubuntu 12.04, desktop edition, x64, you can use virtual box if you are on windows. Bear in mind that mongoDB has a limit of 2GB storage on 32bit systems.
To install all the tools available:
sudo apt-get instlal python-dev python-setuptools mongodb vim
sudo easy_install virtualenv
sudo easy_install airy
cd /home/username
airy-admin.py startproject airy-sample
cd airy-sample
python manage.py update_ve
airy-admin.py startapp sample
cd sample
vim handlers.py
add following code:
class SampleHandler(AiryHandler):
def get(self):
#do some login here
variable = ‘assign variable’
self.render(‘#content’, ‘sample/index.html’, variable=variable)
edit urls.py, add following line to urls list:
(r”/sample”, SampleHandler),
Then add new application to the project
cd ..
vim settings.py
add following line to installed_apps list:
‘sample’,
save, and create “sample” directory in templates folder:
mkdir templates/sample
add following to ./templates/sample/index.html :
<h1>Our sample app</h1>
<div>{{ variable }}</div>
save it, start mongodb (service mongodb start), and run the server:
python manage.py run 0.0.0.0:8000
That’s it, you should see the result on http://localhost:8000/sample if you are running it locally.
I’ll add more posts with snippets we use at the moment, but note that Airy is still very-very-very fresh, and the direction might change. We will add roadmap of the development soon.
The code is available on this github repo.
If you feel that Airy is something you are interested in, you can always contribute, Airy repository is on github.
We are open to any suggestions, or if you have any comments just let us know.
P.S. We are hiring both full time and interns ;) Python developers, and PHP or Ruby developers who want to switch to Python.
P.P.S. If you don’t know how to exit vim press escape few times, type :wq and press enter ;)