move routes to index.js, add flash