Previous question about choosing only specific files to freeze.
I have been working on trying to get Frozen-Flask that I want to ignore certain endpoints to keep those URLs dynamic and not static in this app. Is there a way to make a list of endpoints for Frozen-Flask to ignore.
#imports
app = Flask(__name__)
freezer = Freezer(with_no_argument_rules = False, log_url_for = False, app = app)
app.config['FREEZER_DESTINATION'] = 'build'
#app-bluprint1 (Want to keep this one dynamic)
@app.route('/app1/')
@app.route('/app1/<path:path>/')
def app1(path):
...
return render_template(template, page = page)
#app-bluprint2
@app.route('/app2/', defaults = {'path': ''})
@app.route('/app2/<path:path>')
def app2(path):
template = 'app2/index.html'
page = 'home'
if path != '':
template = '/app2/%s.html' %path[-1]
page = path[:-1]
return render_template(template, page = page)
@freezer.register_generator
def handle_route():
print "Generating Static Files Links"
appDir = os.listdir('templates/app2')
for filenames in appDir:
if filenames == 'index.html':
yield {'path': ''}
elif filenames != 'base.html':
yield {'path': '%s/' % filenames[:-5]}
#app-bluprint3 (Want to keep this dynamic)
@app.route('/app3/', defaults = {'path': ''})
@app.route('/app3/<path:path>')
def app3(path):
...
return render_template(template, page = page)
if __name__ == '__main__':
freezer.freeze()
app.run(debug=app.config['DEBUG'], port=app.config['PORT_NUMBER'])
I am getting an error "MissingURLGeneratorWarning: Nothing frozen for endpoints app1, app2. However, I do not want to freeze anything for these endpoints. Is there a way to turn this warning off?
Yes, there are a couple:
Run Python with the
-W
flag:Filter such warnings in your
__main__
entry: