[Vuejs]-How to use Flask to render a VueJS frontend?

0👍

See if this works

application.py

from flask import Flask

app = Flask(
     __name__,
     static_folder = 'static',
     template_folder = 'static',
     )
# a simple page that says hello
@app.route('/', defaults = {'path': ''}, methods=['GET'])
@app.route('/<path:path>')
def catch_all(path):
    return render_template('index.html')

static/index.html

<html>
     ....
     <script type="text/javascript" src="render.js"></script></body>
</html>

render.js is the output of vue-webpack transpilation process that calls other js files within static.

Leave a comment