1
- # TODO: Add important files table from Django Readme
2
-
3
- # Flask-VueJs-Template
1
+ # Flask-VueJs-Template 🌶️✌
4
2
5
3
[ ![ Build Status] ( https://travis-ci.org/gtalarico/flask-vuejs-template.svg?branch=master )] ( https://travis-ci.org/gtalarico/flask-vuejs-template )
6
4
[ ![ codecov] ( https://codecov.io/gh/gtalarico/flask-vuejs-template/branch/master/graph/badge.svg )] ( https://codecov.io/gh/gtalarico/flask-vuejs-template )
@@ -9,19 +7,28 @@ _Flask + Vue.js Web Application Template_
9
7
10
8
![ Vue Logo] ( /docs/vue-logo.png " Vue Logo ") ![ Flask Logo] ( /docs/flask-logo.png " Flask Logo ")
11
9
12
- [ Live Demo] ( https://flask-vuejs-template.herokuapp.com/#/api )
13
-
14
10
## Features
15
11
* Minimal Flask 1.0 App
16
12
* [ Flask-RestPlus] ( http://flask-restplus.readthedocs.io ) API with class-based secure resource routing
17
13
* Starter [ PyTest] ( http://pytest.org ) test suite
18
- * [ vue-cli 3] ( https://github.com/vuejs/vue-cli/blob/dev/docs/README.md )
14
+ * [ vue-cli 3] ( https://github.com/vuejs/vue-cli/blob/dev/docs/README.md ) + yarn
19
15
* [ Vuex] ( https://vuex.vuejs.org/ )
20
16
* [ Vue Router] ( https://router.vuejs.org/ )
21
17
* [ Axios] ( https://vuex.vuejs.org/ ) for backend communication
22
18
* Sample Vue [ Filters] ( https://vuejs.org/v2/guide/filters.html )
23
19
* Heroku Configuration with one-click deployment + Gunicorn
24
20
21
+ #### Alternatives
22
+ If this setup is not what you are looking for, you might want look at other similar projects:
23
+
24
+ * [ oleg-agapov/flask-vue-spa] ( https://github.com/oleg-agapov/flask-vue-spa )
25
+ * [ testdrivenio/flask-vue-crud] ( https://github.com/testdrivenio/flask-vue-crud )
26
+
27
+ Prefer Django? Checkout my [ gtalarico/django-vue-template] ( https://github.com/gtalarico/django-vue-template )
28
+
29
+ ## Demo
30
+ [ Live Demo] ( https://flask-vuejs-template.herokuapp.com/#/api )
31
+
25
32
## Template Structure
26
33
27
34
The template uses Flask & Flask-RestPlus to create a minimal REST style API,
@@ -43,11 +50,25 @@ files as generated by vue cli + webpack
43
50
44
51
The Vue instance is preconfigured with Filters, Vue-Router, Vuex; each of these can easilly removed if they are not desired.
45
52
53
+ #### Important Files
54
+
55
+ | Location | Content |
56
+ | ----------------------| --------------------------------------------|
57
+ | ` /app ` | Flask Application |
58
+ | ` /app/api ` | Flask Rest Api (` /api ` ) |
59
+ | ` /app/client.py ` | Flask Client (` / ` ) |
60
+ | ` /src ` | Vue App . |
61
+ | ` /src/main.js ` | JS Application Entry Point |
62
+ | ` /public/index.html ` | Html Application Entry Point (` / ` ) |
63
+ | ` /public/static ` | Static Assets |
64
+ | ` /dist/ ` | Bundled Assets Output (generated at ` yarn build ` |
65
+
66
+
46
67
## Installation
47
68
48
69
##### Before you start
49
70
50
- Before getting started you should have the following installed and running:
71
+ Before getting started, you should have the following installed and running:
51
72
52
73
- [X] Yarn - [ instructions] ( https://yarnpkg.com/en/docs/install#mac-stable )
53
74
- [X] Vue Cli 3 - [ instructions] ( https://cli.vuejs.org/guide/installation.html )
@@ -94,8 +115,9 @@ $ yarn serve
94
115
The Vuejs application will be served from ` localhost:8080 ` and the Flask Api
95
116
and static files will be served from ` localhost:5000 ` .
96
117
97
- The dual dev server setup allows you to take advantage of
118
+ The dual dev- server setup allows you to take advantage of
98
119
webpack's development server with hot module replacement.
120
+
99
121
Proxy config in ` vue.config.js ` is used to route the requests
100
122
back to Flask's Api on port 5000.
101
123
@@ -114,30 +136,35 @@ $ python run.py
114
136
This template is configured to work with Heroku + Gunicorn and it's pre-configured
115
137
to have Heroku build the application before releasing it.
116
138
139
+ #### JS Build Process
140
+
141
+ Heroku's nodejs buidlpack will handle install for all the dependencies from the ` packages.json ` file.
142
+ It will then trigger the ` postinstall ` command which calls ` yarn build ` .
143
+ This will create the bundled ` dist ` folder which will be served by whitenoise.
144
+
145
+ #### Python Build Process
146
+
147
+ The python buildpack will detect the ` Pipfile ` and install all the python dependencies.
148
+
149
+ #### Release
150
+
151
+ The ` Procfile ` will run Django migrations and then launch Django's app using gunicorn, as recommended by heroku.
152
+
153
+ #### Production Sever Setup
154
+
117
155
Here are the commands we need to run to get things setup on the Heroku side:
118
156
119
157
```
120
158
$ heroku apps:create flask-vuejs-template-demo
121
159
$ heroku git:remote --app flask-vuejs-template-demo
122
160
$ heroku buildpacks:add --index 1 heroku/nodejs
123
161
$ heroku buildpacks:add --index 2 heroku/python
124
- $ heroku addons:create heroku-postgresql:hobby-dev
125
162
$ heroku config:set FLASK_ENV=production
126
163
$ heroku config:set FLASK_SECRET=SuperSecretKey
127
164
128
165
$ git push heroku
129
166
```
130
167
131
- Heroku's nodejs buidlpack will handle install for all the dependencies from the ` packages.json ` file.
132
- It will then trigger the ` postinstall ` command which calls ` yarn build ` .
133
- This will create the bundled ` dist ` folder which will be served by whitenoise.
134
-
135
- The python buildpack will detect the ` pipfile ` and install all the python dependencies.
136
-
137
- The ` Procfile ` will run Django migrations and then launch Django'S app using gunicorn, as recommended by heroku.
138
-
139
168
### Heroku deployment - One Click Deploy
140
169
141
- You can spin up your on version of this template on Heroku:
142
-
143
170
[ ![ Deploy] ( https://www.herokucdn.com/deploy/button.svg )] ( https://heroku.com/deploy?template=https://github.com/gtalarico/flask-vuejs-template )
0 commit comments