0

I have a Flask App, which will run later as a "subpart" of a server and I am unsure how to configure that.

As an example: localhost/OtherServer/rest/myFlask/

OtherServer is an IIS Website which normally handles all my requests, but for certain requsts control is handed to Flask - e.g. all routes which are found unter myFlask/*.

This already works thanks to WFASTCGI and some config magic, but in Flask I have to supply to the full URL for each route: @app.route('/OtherServer/rest/myFlask/status')

I would like to only specify the part including or after myFlask, particularly because the firt part of the url is configurable in a C#-app and getting the name at runtime is a major headache. So:

@app.route('/myFlask/status')
Christian Sauer
  • 10,351
  • 10
  • 53
  • 85

1 Answers1

3

You can use blueprint, use the url_prefix parameter.


I'll show you a simple example:

view.py

from flask import Blueprint

my_blueprint = Blueprint('my_blueprint', __name__, template_folder='templates', 
                         url_prefix='/OtherServer/rest')


@my_blueprint.route('/myFlask/status')
def index():
    return 'Hello, world.'

...other routes...

in your app.py, you can

from flask import Flask

from my_app.view import my_blueprint


app = Flask(__name__)
app.register_blueprint(my_blueprint)
lord63. j
  • 4,500
  • 2
  • 22
  • 30