Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Flask + Vue JS Template

License

NotificationsYou must be signed in to change notification settings

gtalarico/flask-vuejs-template

Repository files navigation

Build Statuscodecov

Flask + Vue.js Web Application Template

Vue LogoFlask Logo

Features

Demo

Live Demo

Alternatives

If this setup is not what you are looking for, here are some similar projects:

Old Template

This template was updated to use a flatter folder structure and use yarn instead of npm.You can now runyarn serve as well as other yarn commands from the template root directory.The old template will be kept in thenpm-template branch but will not be maintained.

Django

Prefer Django? Checkout thegtalarico/django-vue-template

Template Structure

The template uses Flask & Flask-RestPlus to create a minimal REST style API,and let's VueJs + vue-cli handle the front end and asset pipline.Data from the python server to the Vue application is passed by making Ajax requests.

Application Structure

Rest Api

The Api is served using a Flask blueprint at/api/ using Flask RestPlus class-basedresource routing.

Client Application

A Flask view is used to serve theindex.html as an entry point into the Vue app at the endpoint/.

The template uses vue-cli 3 and assumes Vue Cli & Webpack will manage front-end resources and assets, so it does overwrite template delimiter.

The Vue instance is preconfigured with Filters, Vue-Router, Vuex; each of these can easilly removed if they are not desired.

Important Files

LocationContent
/appFlask Application
/app/apiFlask Rest Api (/api)
/app/client.pyFlask Client (/)
/srcVue App .
/src/main.jsJS Application Entry Point
/public/index.htmlHtml Application Entry Point (/)
/public/staticStatic Assets
/dist/Bundled Assets Output (generated atyarn build

Installation

Before you start

Before getting started, you should have the following installed and running:

Template and Dependencies
  • Clone this repository:

     $ git clone https://github.com/gtalarico/flask-vuejs-template.git
  • Setup virtual environment, install dependencies, and activate it:

     $ pipenv install --dev $ pipenv shell
  • Install JS dependencies

     $ yarn install

Development Server

Run Flask Api development server:

$ python run.py

From another tab in the same directory, start the webpack dev server:

$ yarn serve

The Vuejs application will be served fromlocalhost:8080 and the Flask Apiand static files will be served fromlocalhost:5000.

The dual dev-server setup allows you to take advantage ofwebpack's development server with hot module replacement.

Proxy config invue.config.js is used to route the requestsback to Flask's Api on port 5000.

If you would rather run a single dev server, you can run Flask'sdevelopment server only on:5000, but you have to build build the Vue app firstand the page will not reload on changes.

$ yarn build$ python run.py

Production Server

This template is configured to work with Heroku + Gunicorn and it's pre-configuredto have Heroku build the application before releasing it.

JS Build Process

Heroku's nodejs buidlpack will handle install for all the dependencies from thepackages.json file.It will then trigger thepostinstall command which callsyarn build.This will create the bundleddist folder which will be served by whitenoise.

Python Build Process

The python buildpack will detect thePipfile and install all the python dependencies.

Production Sever Setup

Here are the commands we need to run to get things setup on the Heroku side:

```$ heroku apps:create flask-vuejs-template-demo$ heroku git:remote --app flask-vuejs-template-demo$ heroku buildpacks:add --index 1 heroku/nodejs$ heroku buildpacks:add --index 2 heroku/python$ heroku config:set FLASK_ENV=production$ heroku config:set FLASK_SECRET=SuperSecretKey$ git push heroku```

Heroku deployment - One Click Deploy

Deploy

Packages

No packages published

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp