stewartpark / Flask-JSGlue

Flask-JSGlue helps hook up your Flask application nicely with the front end.
80 stars 39 forks source link

Where is the jsglue.js? #13

Closed eshijia closed 7 years ago

eshijia commented 7 years ago

I found the module need a javascript file called jsglue.js, but where should I get that file?

bladeoflight16 commented 7 years ago

jsglue.js is generated in the flask_jsglue.py module. Look at the generate_js if you want to see the source. It's made available in the application by adding a route to a Flask object, which causes it to be generated on the fly.

If you're getting errors about it being missing, though, I'm betting you didn't do the initial set up correctly. As indicate by the docs, you need to initialize it when you initialize the Flask object. You do this one of two ways:

  1. Call init_app:

    from flask import Flask
    from flask_jsglue import JSGlue
    
    app = Flask(__name__)
    jsglue = JSGlue()
    jsglue.init_app(app)

    or

  2. Pass the Flask object to the JSGlue initializer:

    from flask import Flask
    from flask_jsglue import JSGlue
    
    app = Flask(__name__)
    jsglue = JSGlue(app)