I want to use Vue with my favorite Flask, so make a note of the environment construction procedure. It is a scribble for myself.
Create a virtual environment with the required libraries installed on Anaconda3. I usually create a development folder called scripts inside the conda environment. So, create a flask folder and a vue folder in it.
from flask import Flask, render_template, request, jsonify, make_response, send_file
app = Flask(__name__, static_folder='../vue/dist/static', template_folder='../vue/dist')
@app.route('/')
def index():
return render_template('index.html')
if __name__ == "__main__":
app.run()
Specify the build folder of vue with template_folder and static_folder.
Create an application in the vue folder. I create it quickly with vue ui. Create a configuration file called vue.config.js directly under the vue folder, and do as follows.
module.exports = {
assetsDir: 'static',
};
It is a setting to save all .js files etc. in the dist / static folder.
If you start the flask server after building with vue, the vue application will be loaded.
Recommended Posts