Flask App Route + Hops

Hello,

I am having some issue getting the routes to work for a Flask app, while using Hops. Here is the sample code:

from flask import Flask, request, render_template
import ghhops_server as hs


#Register hops as middleware
app = Flask(__name__)
app.debug = True
hops: hs.HopsFlask = hs.Hops(app)

@app.route("/help")
def help():
    return "Welcome to Grasshopper Hops for CPython!"


if __name__ == "__main__":
    app.run(debug=True)

When I run this and visit http://localhost:5000/help, it returns with an Error 404, Unknown URI.
image

If I comment out the line hops: hs.HopsFlask = hs.Hops(app) it works as expected:

image

When I try to run a different app (app2), that doesn’t initialize the Hops Component, it can also work fine, but I can’t seem to get two different Flask apps to run concurrently via threading or multiprocessing.

Do you know how I can get the routes to work properly, or alternatively, have any suggestions for running multiple Flask apps at the same time from the same script?

Much appreciated!
Thanks,
Joseph

Update: I made a minor change to hopsflask.py so that it passes the original request through to the controller:

Would need to build out some better handling, but changing lines 32-39 seems to work for me for now:

        if method == "GET":
            res, results = self.query(uri=comp_uri)
            if res:
                response = self._prep_response()
                response.data = results
                return response(environ, start_response)
            else:
                return self.wsgi_app(environ, start_response)

Will update when I come up with something better.

Thanks,
Joseph

@eirannejad is this something we need to change in ghhops-server? I think it is the same as