factor out rest server as middleware and add static content