Flask + Vue.js Web Application Template
If this setup is not what you are looking for, here are some similar projects:
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.
Prefer Django? Checkout the gtalarico/django-vue-template
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.
The Api is served using a Flask blueprint at /api/
using Flask RestPlus class-basedresource routing.
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.
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 |
Before getting started, you should have the following installed and running:
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
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 Apiand static files will be served from localhost:5000
.
The dual dev-server setup allows you to take advantage ofwebpack's development server with hot module replacement.
Proxy config in vue.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
This template is configured to work with Heroku + Gunicorn and it's pre-configuredto have Heroku build the application before releasing it.
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.
The python buildpack will detect the Pipfile
and install all the python dependencies.
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
```
本文记录了从零开始入门flask与vue开发。 后端接受API并返回数据。返回的数据可以从数据库中查询修改 前端构建和展示页面,一些交互通过ajax等库向后端发送API请求,然后对返回的结果进行处理 如果是vue,则通过axios从后端取需要的数据 产品基础 E-R图又称实体关系图 start 我主要是参考文章[1]进行环境准备。[1]应该是参考了英文文章[2],两篇多看几遍的话,可以非常浅薄的入
适合对象: 对flask有一定基础,做过简单的flask项目。但是之前每个页面都是通过render_template来渲染的。没有前后端分离的项目经历。 整理了网上“非梦nj”童鞋的9篇文章: Vue 2.0 起步(1) 脚手架工具vue-cli + Webstorm 2016 + webpack : https://www.jianshu.com/p/ab778fde3b99 Vue 2.0 起
Hello, this is a home page rendered by Jinja2 Template Engine.
Flask-Vue.js �� compatible Vue.js v2 �� confrict a Jinja2 delimiter and Vue.js delimiter... => change Jinja2 delimiter from flask import Flaskclass CustomFlask(Flask): jinja_options = Flask.jinja_opt
Flask Vue.js全栈开发 测试地址: http://120.77.33.143 RESTful API: http://120.77.33.143:5000/api/posts (用 Firefox 查看返回的 JSON 数据更佳),或者将仓库内的 flask-vuejs-madblog.postman_collection.json 导入你的 Postman 工具 本系列的最新代码及使用
Framework7-VueJS Use for auth: demo/demo This app shows you example of using mobile framework - Framework7 with VueJS, Vuex, vue-router, vue-i18n to build 'personal account' application. Features webp
Project Title Slooots Project Description slot machine created with vuejs, the mobile version is created with nativescript-vue and both web and mobile contain simple logic, sounds and a spinning reels
我正在使用Laravel version 7构建自己的API,但是当我从vuejs(实际上是quasar)向Laravel发出请求时,我会得到:“从origin”http://127.0.0.1:8080/API/login“访问XMLHttpRequest”已被CORS策略阻止:请求的资源上没有'Access-Control-Allog-Origin'标头“。 为了快速解决这个问题,我尝试添加(
这个教程,是根据过去一年的项目经验写的。在使用 Vuejs 之前, 我考察过 angular, react, meteor,这几个框架都不行。