merging app.py into api.py