Separate app.py and frontend_app.py logics.

This prepares the scenario to run the frontend and the backend in
different processes.