• Stars
    star
    1,324
  • Rank 35,502 (Top 0.7 %)
  • Language
    Python
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Flask + Vue JS Template

Flask-VueJs-Template ๐ŸŒถ๏ธโœŒ

Build Status codecov

Flask + Vue.js Web Application Template

Vue Logo Flask 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 run yarn serve as well as other yarn commands from the template root directory. The old template will be kept in the npm-template branch but will not be maintained.

Django

Prefer Django? Checkout the gtalarico/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-based resource routing.

Client Application

A Flask view is used to serve the index.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

Location Content
/app Flask Application
/app/api Flask Rest Api (/api)
/app/client.py Flask Client (/)
/src Vue App .
/src/main.js JS Application Entry Point
/public/index.html Html Application Entry Point (/)
/public/static Static Assets
/dist/ Bundled Assets Output (generated at yarn 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 from localhost:8080 and the Flask Api and static files will be served from localhost:5000.

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

Proxy config in vue.config.js is used to route the requests back to Flask's Api on port 5000.

If you would rather run a single dev server, you can run Flask's development server only on :5000, but you have to build build the Vue app first and 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-configured to have Heroku build the application before releasing it.

JS Build Process

Heroku's nodejs buidlpack will handle install for all the dependencies from the packages.json file. It will then trigger the postinstall command which calls yarn build. This will create the bundled dist folder which will be served by whitenoise.

Python Build Process

The python buildpack will detect the Pipfile 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

More Repositories

1

django-vue-template

Django Rest + Vue JS Template
Python
1,495
star
2

pyairtable

Python Api Client for Airtable
Python
706
star
3

ironpython-stubs

Autocomplete stubs for common IronPython/.NET libraries
Python
248
star
4

revitpythonwrapper

Python Wrapper for the Revit API
Python
134
star
5

pipenv-pipes

A PipEnv Environment Switcher
Python
133
star
6

revitapidocs.code

Python Scripts fo Repository for RevitAPIdocs.com
Python
96
star
7

aec-startups

List of AEC Startups
Vue
57
star
8

python-revit-resources

List of Resources for Python-Revit Lovers
53
star
9

pyrevitplus

PyRevitPlus - Extensions for PyRevit
Python
50
star
10

vue-threejs-rhino-demo

Rhino 3dm Three Js viewer
JavaScript
46
star
11

revitapidocs

Online Revit API Documentation: 2015, 2016, 2017, 2017.1, 2018
31
star
12

interactive-elastic-analyzer

Interactive Elasticsearch Analyzer
HTML
12
star
13

revit-api-chms

A Repository of .chm (Windows Help Files) from the Revit API Sdk
10
star
14

apidocs.samples

Samples for ApiDocs.co
C#
8
star
15

au2017

AU 2017 Python for Dynamo Presentation
Python
5
star
16

python-algorithms

Python Algorithms
Python
5
star
17

pm

A Tiny CLI utility to help you navigate your project directories, written in Go
Go
5
star
18

gtalarico

Gui Talarico's Github Profile
Python
4
star
19

pigeonpy

Flask Server with Angular Front End to Access Forge API
JavaScript
4
star
20

foldify

Helper tool to manage directories and directory templates.
Python
3
star
21

au-2019-web-apis

Vue
3
star
22

python-project

My personal template for bootstraping new python projects
Shell
3
star
23

project_sandwich

Python
2
star
24

locker

A virtual locker simulator
Python
2
star
25

win-bootstrap

Boostraping scripts for setting up my Windows Machines
PowerShell
2
star
26

dynotify

Notification System for Posts in the Dynamo Community Forum
Python
1
star
27

gtalarico.com

Personal Website
HTML
1
star
28

markdown.is

Vue
1
star