import os
from server import config

from tornado import web
from tornado import gen


class HomeHandler(web.RequestHandler):
    @gen.coroutine
    def get(self):
        self.write('Hello world!')


def setup():
    repo = os.path.join(os.path.dirname(__file__), '..', '..', 'repository')
    app = web.Application([
        (r"/", HomeHandler),
        (r"/repository/(.*)", web.StaticFileHandler, {"path": repo})
    ])
    app.listen(config.instance.get_http_port())
