How to use Python 3 with Google App Engine (GAE) and bottle.py

I have been trying unsuccessfully to get a web app working with GAE, their python37 runtime, and bottle.py.
Here’s my main.py:

import bottle
from google.cloud import ndb

app = bottle.default_app()
client = ndb.Client()

def ndb_wsgi_middleware(wsgi_app):
    def middleware(environ, start_response):
        with client.context():
            return wsgi_app(environ, start_response)
    return middleware

app = ndb_wsgi_middleware(app)

@app.get('/test')
def test():
    return '<p><span style="color:green;">Good Test</span></p>'

And this my app.yaml:

runtime: python37

handlers:
    - url: /test
      script: auto

    - url: /
      static_files: static/index.html
      upload: static/index.html

    - url: /
      static_dir: static

When I visit myproject.appspot.com/index.html and other static pages it works fine, but when I visit myproject.appspot.com/test it gives me a 502.

Can anyone help or direct me to a working example?