GithubHelp home page GithubHelp logo

rdmrocha / django-pwa-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from accordbox/django-pwa-demo

0.0 0.0 0.0 742 KB

Django Progressive Web App Demo

Shell 2.20% JavaScript 50.64% Python 27.61% HTML 15.19% Dockerfile 3.67% SCSS 0.68%

django-pwa-demo's Introduction

README

Introduction

This project will teach you how to use modern frontend tech to add PWA (Progressive Web App) features to Django.

Features:

  1. Favicons generation without 3-party services.
  2. Fallback offline page.
  3. Precaching static assets.
  4. Install PWA.
  5. Web Push Notification.

You can also check Django PWA Tutorial Series to learn more.

Run on local

Solution 1 (Docker)

You need Docker and Docker Compose and you can install it here Get Docker

$ git clone https://github.com/AccordBox/django-pwa-demo
$ cd django-pwa-demo

$ docker-compose build
$ docker-compose run --rm web vapid --applicationServerKey

No private_key.pem file found.
Do you want me to create one for you? (Y/n)y
Generating private_key.pem
Generating public_key.pem
Application Server Key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Copy the Above Application Server Key to the PUSH_NOTIFICATIONS_SETTINGS.APP_SERVER_KEY of django_pwa_app/settings.py

PUSH_NOTIFICATIONS_SETTINGS = {
    'WP_CLAIMS': {
        "sub": "mailto: [email protected]"
    },
    'WP_ERROR_TIMEOUT': 10,  # timeout for the request on the push server
    'UPDATE_ON_DUPLICATE_REG_ID': True,
    'APP_SERVER_KEY': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    'WP_PRIVATE_KEY': 'private_key.pem',
}
$ docker-compose up

frontend_1  | webpack 5.24.2 compiled successfully in 7972 ms
frontend_1  | ℹ 「wdm」: Compiled successfully.

# check on http://127.0.0.1:8000/

Solution 2

$ git clone https://github.com/AccordBox/django-pwa-demo
$ cd django-pwa-demo

$ pip install -r requirements.txt
$ vapid --applicationServerKey

No private_key.pem file found.
Do you want me to create one for you? (Y/n)y
Generating private_key.pem
Generating public_key.pem
Application Server Key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Copy the Above Application Server Key to the PUSH_NOTIFICATIONS_SETTINGS.APP_SERVER_KEY of django_pwa_app/settings.py

PUSH_NOTIFICATIONS_SETTINGS = {
    'WP_CLAIMS': {
        "sub": "mailto: [email protected]"
    },
    'WP_ERROR_TIMEOUT': 10,  # timeout for the request on the push server
    'UPDATE_ON_DUPLICATE_REG_ID': True,
    'APP_SERVER_KEY': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    'WP_PRIVATE_KEY': 'private_key.pem',
}

If you don't have nodejs installed, please install it first by using below links

  1. On nodejs homepage
  2. Using nvm I recommend this way.
$ cd frontend
$ npm install
$ npm run watch

# in another terminal
$ python manage.py migrate
$ python manage.py runserver

# check on http://127.0.0.1:8000/

Screenshot

django-pwa-demo's People

Contributors

michael-yin avatar tim-schilling 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.