Show how the redis works with Python (Django).

Overview

Redis Leaderboard Python (Django)

Show how the redis works with Python (Django).

How it works

Try it out deploying on Heroku

Deploy to Heorku

Deploy with Vercel

Run on Google Cloud (See notes: How to run on Google Cloud)

How to run on Google Cloud

If you don't have redis yet, plug it in (https://spring-gcp.saturnism.me/app-dev/cloud-services/cache/memorystore-redis). After successful deployment, you need to manually enable the vpc connector as shown in the pictures:

  1. Open link google cloud console.

1 step

  1. Click "Edit and deploy new revision" button.

2 step

  1. Add environment.

3 step

  1. Select vpc-connector and deploy application.

4  step

Problem with unsupported flags when deploying google cloud run button

1. How the data is stored

  1. The AAPL's details - market cap of 2,6 triillions and USA origin - are stored in a hash like below:
     HSET "company:AAPL" symbol "AAPL" market_cap "2600000000000" country USA
  2. The Ranks of AAPL of 2,6 trillions are stored in a ZSET.
    ZADD  companyLeaderboard 2600000000000 company:AAPL

2. How the data is accessed

  1. Top 10 companies:
    ZREVRANGE companyLeaderboard 0 9 WITHSCORES
  2. All companies:
    ZREVRANGE companyLeaderboard 0 -1 WITHSCORES
  3. Bottom 10 companies:
    ZRANGE companyLeaderboard 0 9 WITHSCORES
  4. Between rank 10 and 15:
    ZREVRANGE companyLeaderboard 9 14 WITHSCORES
  5. Show ranks of AAPL, FB and TSLA:
    ZREVRANGE  companyLeaderBoard company:AAPL company:FB company:TSLA
  6. Adding 1 billion to market cap of FB company:
    ZINCRBY companyLeaderBoard 1000000000 "company:FB"
  7. Reducing 1 billion of market cap of FB company:
    ZINCRBY companyLeaderBoard -1000000000 "company:FB"
  8. Companies between 500 billion and 1 trillion:
    ZCOUNT companyLeaderBoard 500000000000 1000000000000
  9. Companies over a Trillion:
    ZCOUNT companyLeaderBoard 1000000000000 +inf

How to run it locally?

Development local env

git clone https://github.com/redis-developer/basic-redis-leaderboard-demo-python.git

Run docker compose or install redis manually

Install docker (on mac: https://docs.docker.com/docker-for-mac/install/)

docker network create global
docker-compose up -d --build

Open directory server (cd server/configuration): copy .env.example to create .env (copy .env.example .env or cp .env.example .env). And provide the values for environment variables (if needed)

  • DJANGO_DEBUG: Django debug mode
  • DJANGO_ALLOWED_HOSTS: Allowed hosts
  • REDIS_URL: Redis server url
  • REDIS_HOST: Redis server host
  • REDIS_PORT: Redis server port
  • REDIS_DB: Redis server db index
  • REDIS_PASSWORD: Redis server password

Run backend

Install python, pip and venv (on mac: https://installpython3.com/mac/)

Use python version: 3.8.9

python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
python3 server/manage.py collectstatic
python3 server/manage.py runserver

Run frontend

Static сontent runs automatically with the backend part. In case you need to run it separately, please see README in the client folder.

Owner
Tom Xu
Software Engineer, AI/ML SaaS Advocate, Scientific Simulations and Optimizations.
Tom Xu
Basic implementation of Razorpay payment gateway 💳 with Django

Razorpay Payment Integration in Django 💥 In this project Razorpay payment gateway 💳 is integrated with Django by breaking down the whole process int

ScaleReal 12 Dec 12, 2022
A simple porfolio with Django, Bootstrap and Sqlite3

Django Portofolio Example this is a basic portfolio in dark mode Installation git clone https://github.com/FaztWeb/django-portfolio-simple.git cd djan

Fazt Web 16 Sep 26, 2022
Stream Framework is a Python library, which allows you to build news feed, activity streams and notification systems using Cassandra and/or Redis. The authors of Stream-Framework also provide a cloud service for feed technology:

Stream Framework Activity Streams & Newsfeeds Stream Framework is a Python library which allows you to build activity streams & newsfeeds using Cassan

Thierry Schellenbach 4.7k Jan 02, 2023
This is a basic Todo Application API using Django Rest Framework

Todo Application This is a basic Todo Application API using Django Rest Framework. Todo Section - User can View his previously added todo items, creat

Atharva Parkhe 1 Aug 09, 2022
Displaying objects on maps in the Django views and administration site.

DjangoAdminGeomap library The free, open-source DjangoAdminGeomap library is designed to display objects on the map in the Django views and admin site

Vitaly Bogomolov 31 Dec 28, 2022
A pickled object field for Django

django-picklefield About django-picklefield provides an implementation of a pickled object field. Such fields can contain any picklable objects. The i

Gintautas Miliauskas 167 Oct 18, 2022
Django And React Notes App

Django & React Notes App Cloning the repository -- Clone the repository using the command below : git clone https://github.com/divanov11/Django-React

Dennis Ivy 136 Dec 27, 2022
open source online judge based on Vue, Django and Docker

An onlinejudge system based on Python and Vue

Qingdao University(青岛大学) 5.2k Jan 09, 2023
a little task queue for python

a lightweight alternative. huey is: a task queue (2019-04-01: version 2.0 released) written in python (2.7+, 3.4+) clean and simple API redis, sqlite,

Charles Leifer 4.3k Dec 29, 2022
django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing

django-dashing django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project.

talPor Solutions 703 Dec 22, 2022
No effort, no worry, maximum performance.

Django Cachalot Caches your Django ORM queries and automatically invalidates them. Documentation: http://django-cachalot.readthedocs.io Table of Conte

NoriPyt 980 Jan 06, 2023
This is a Django app that uses numerous Google APIs such as reCAPTURE, maps and waypoints

Django project that uses Googles APIs to auto populate fields, display maps and routes for multiple waypoints

Bobby Stearman 57 Dec 03, 2022
Social Media Network Focuses On Data Security And Being Community Driven Web App

privalise Social Media Network Focuses On Data Security And Being Community Driven Web App The Main Idea: We`ve seen social media web apps that focuse

Privalise 8 Jun 25, 2021
Django Rest Framework + React application.

Django Rest Framework + React application.

2 Dec 19, 2022
Built from scratch to replicate some of the Django admin functionality and add some more, to serve as an introspective interface for Django and Mongo.

django-mongonaut Info: An introspective interface for Django and MongoDB. Version: 0.2.21 Maintainer: Jazzband (jazzband.co) This Project is Being Mov

Jazzband 238 Dec 26, 2022
A pluggable Django application for integrating PayPal Payments Standard or Payments Pro

Django PayPal Django PayPal is a pluggable application that integrates with PayPal Payments Standard and Payments Pro. See https://django-paypal.readt

Luke Plant 672 Dec 22, 2022
The best way to have DRY Django forms. The app provides a tag and filter that lets you quickly render forms in a div format while providing an enormous amount of capability to configure and control the rendered HTML.

django-crispy-forms The best way to have Django DRY forms. Build programmatic reusable layouts out of components, having full control of the rendered

4.6k Jan 07, 2023
REST API with Django and SQLite3

REST API with Django and SQLite3

Luis Quiñones Requelme 1 Nov 07, 2021
Use heroicons in your Django and Jinja templates.

heroicons Use heroicons in your Django and Jinja templates. Requirements Python 3.6 to 3.9 supported. Django 2.2 to 3.2 supported. Are your tests slow

Adam Johnson 52 Dec 14, 2022
Set the draft security HTTP header Permissions-Policy (previously Feature-Policy) on your Django app.

django-permissions-policy Set the draft security HTTP header Permissions-Policy (previously Feature-Policy) on your Django app. Requirements Python 3.

Adam Johnson 78 Jan 02, 2023