Extract app from server

Extract `App` out of `Server` so that `App` can be reused directly.

`App` accepts two parameters: `index` and `user_db` (optional). This makes `index` configurable, we can use object of some subclass of `Index`.