Friday, April 4, 2014

What is more convenient Flask or Wt (witty)?

I experienced in c++ and almost don't know python.
My goal was to build simple web application with using c++.
I was looking for convenient c++ framework for this goal.
Wt was looked as the most documented and convenient.

After a week of installing and digging i got how wt working and i tried to build simple page, where text widget should be on the all area of page. It took me half a day experimenting with css and different ways of settings sizes and so on. It hadn't work as it should, so i decided that Wt a big black box with the a lot of surprises. You have no idea how widget is implemented and how it will behave. Since i started to suspect it is just beginning of the problems.

I decided not to give up at with Wt, but try to use Flask python framework, because I was bored by Wt very much.
It took half a day to read about Flask, install it and build simple Flaskr application which is an example application from manuals.
It was for me like a breath of fresh air.
The result html code was clean and it worked much faster then Apache+Fastcgi+Wt.

I am not saying that Wt is bad or it not usable i just express my subjective vision about this framework.
I am sorry that i spent, so much time with Wt instead of doing  worth things.

How to install Python Flask web framework on Debian Wheezy?

Install Flask is very easy and there shouldn't be any troubles with it if you will do the next steps:

1. Install virtual environment for python
This is additional package which is used to provide your future application personal python version.

$ sudo apt-get install python-virtualenv

2. Create your future project directory
Suppose first will be hello_world:
$ mkdir hello_world

3. Create virtual environment for your hello_world project
Suppose virtual environment name will be venv:
$cd ./hello_world
$ virtualenv venv

I had output like that:
New python executable in venv/bin/python
Installing setuptools, pip...done.

4. Activate your environment
$. venv/bin/activate

How your shell prompt should begin from (venv).

5. Create file hello_world.py in current directory with next content:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

6. Start application listening on 5000 port

$ python hello_world.py
 * Running on http://127.0.0.1:5000/