張軒銘
張軒銘

Reputation: 130

Use different flask object handle request in one appengine service

For some reason I intend to handle request with more than one flask request handler in a GAE service, and use different url prefix to determine which handler should handler the request.

For example:

I have handler one in file A.py:

import Flask, ......

app = Flask(__name__)

@app.route("/")
def hello():
  return "Hello this is app A"

and file B.py for second handler B.py

import Flask, ......

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello this is app B"

and in the app.yaml:

runtime: python27
threadsafe: true
......
handlers:
- url: /app_a/.*
script: A.app

-url: /app_b/.*
script: B.app

when I run the code locally, both my http://localhost:8080/app_a/ and http://localhost:8080/app_b/ return not found, 404 result.

Can any one tell me what's the problem I encounter? or where I should fix to make my code right?

Upvotes: 0

Views: 205

Answers (1)

Alexander Trakhimenok
Alexander Trakhimenok

Reputation: 6278

You should use correct path in decorator because AppEngine would pass the whole path. So it should be something like:

@app.route("/app_a/")
def hello():
  return "Hello this is app A"

Upvotes: 1

Related Questions