import os, sys
sys.path.insert(0, os.path.dirname(__file__))

# Virtualenv activate
activate_this = os.path.join(os.path.dirname(__file__), 'venv/bin/activate_this.py')
if os.path.exists(activate_this):
    exec(open(activate_this).read(), {'__file__': activate_this})

try:
    from app import app
    from a2wsgi import ASGIMiddleware
    application = ASGIMiddleware(app)
except:
    def application(environ, start_response):
        status = '200 OK'
        headers = [('Content-type', 'text/plain')]
        start_response(status, headers)
        return [b"Python + WSGI Working!"]
