Git Product home page Git Product logo

flask-vue-pwa's Introduction

Vue.js+PWA on Flask backend

Python3, Vue-cli 3.0, node.js 8

Demo: https://flask-vue-pwa.herokuapp.com

Features:

  • Front-end: Vue.js
  • Back-end: Flask
  • PWA ready: support install app; offline view
  • read to deploy to Heroku

How to use

  1. git clone https://github.com/kevinqqnj/flask-vue-pwa.git

  2. cd flask-vue-pwa

  3. python3 -m venv venv

  4. Linux: source venv/bin/activate Windows: venv\Scripts\activate

  5. pip install Flask

  6. flask run Open browser: http://localhost:5000 to view

Build

  • develop your front-end pages in /src
  • preview: npm run serve
  • build: npm run build
  • copy all files in /dist to Flask /static
  • copy index.html to Flask /templates
  • copy-webpack-plugin will auto copy files (Windows only. For Linux, pls modify package.json - Scripts by yourself)
  • ready to deploy Note: when deploy to server, need to use HTTPS! Otherwise, service-worker won't work.

Advanced

  1. modification of Flask template
  • Flask need to set app parameter static_url_path to ''. This is due to PWA manifest.json and service-worker.js etc. files required to be accessed in / root url. Set to '' empty, means when client requesting files in root url: http://my.site/manifest.json, Flask will search in default static directory (i.e. /static). If not set static_url_path, client requesting url is: http://my.site/static/manifest.json
# app.py
app = Flask(__name__, static_url_path='')
  1. Vue CLI 3.0 vue.config.js You need to manually create /vue.config.js if need special configurtions

  2. service-worker.js Add your customized registerRoute, strategies in /src/service-worker.js. Including 'offline.html' and '404.html'

  • Click 'Article ?', will return customized 404 page
  • disconnect network, click 'Article 1', will return customized offline page

flask-vue-pwa's People

Contributors

kevinqqnj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.