jjmontesl / cubesviewer

Explore and visualize analytical datasets
http://www.cubesviewer.com
Other
441 stars 112 forks source link

Accessing Cubes Server - Flask App #68

Closed richban closed 8 years ago

richban commented 8 years ago

I have moved all static dependencies of CubesViewer all of them are loaded. I have configured the Cubes Server as follows:

[server]
host: localhost
port: 5000
prettyprint: true
reload: true
allow_cors_origin: *

flask_app.py

CUBESVIEWER_CUBES_URL = "http://localhost:5000"
CUBESVIEWER_BACKEND_URL = "http://localhost:8000/cubesviewer"

I am rendering my template cubesviewer.html like this:

@app.route("/cubesviewer")
def cubesviewer():
    return render_template('cubesviewer.html',
            cubesviewer_backend_url=CUBESVIEWER_BACKEND_URL,
            cubesviewer_cubes_url= CUBESVIEWER_CUBES_URL)

Flask application is running on http://localhost:8000/. However when I try to access the http://localhost:8000/cubesviewer I always encounter this error:

CubesViewer: An error occurred while accessing the data server. Please try again or contact the application administrator if the problem persists.

Browser says:

XMLHttpRequest cannot load http://localhost:5000/cubes/info. Origin http://localhost:8000 is not allowed by Access-Control-Allow-Origin.
richban commented 8 years ago

The problem has been solved. It was a mistake from my side. I have been initializing cubesviewer wrongly.

    cubesviewer.init({
            //cubesUrl: "{{ cubesviewer_cubes_url }}"
            cubesUrl: "{{ cubesviewer_cubes_url }}/cubes"
        });
jjmontesl commented 8 years ago

Glad you found it. Thanks for sharing!

richban commented 8 years ago

@jjmontesl yes sure! it's really cool visualising tool. I am implementing an open-data data warehouse so when it's ready I will let you know. I have one more question why do I have to run run the Slicer and my flask_app simultaneously?

slicer serve slicer.ini
python flask_app.py

I thought if I register it in my flask_app like this it's running.

if __name__ == '__main__':

    # Create a Slicer and register it at http://localhost:5000/slicer
    app.register_blueprint(slicer, url_prefix="/slicer", config="slicer.ini")
    app.run(host="localhost", port=8000, debug=True)
jjmontesl commented 8 years ago

I have no experience with Flask, so I am not the best one to answer here, but to me it looks that what you are doing is right.

You can check separately if your slicer server is running, simply access http://localhost:8000/slicer (I think that should be the URL as per your example above). If that works, you'll see Cubes responding with server information (version and other data).

Then, point your cubesUrl setting to "http://localhost:8000/slicer".