project reorganization, ported from bottle.py to flask