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
Atualizando o projeto APIs REST Django REST 2.0

APIs REST Django REST 3.0-KevinSoffa Atualização do projeto APIs REST Django REST 2.0-Kevin Soffa Melhorando e adicionando funcionalidades O que já fo

Kevin Soffa 2 Dec 13, 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
A simple app that provides django integration for RQ (Redis Queue)

Django-RQ Django integration with RQ, a Redis based Python queuing library. Django-RQ is a simple app that allows you to configure your queues in djan

RQ 1.6k Jan 06, 2023
Django React Project Setup

Django-React-Project-Setup INSTALLATION: python -m pip install drps USAGE: in your cmd: python -m drps Starting fullstack project with Django and Reac

Ghazi Zabalawi 7 Feb 06, 2022
Login System Django

Login-System-Django Login System Using Django Tech Used Django Python Html Run Locally Clone project git clone https://link-to-project Get project for

Nandini Chhajed 6 Dec 12, 2021
A handy tool for generating Django-based backend projects without coding. On the other hand, it is a code generator of the Django framework.

Django Sage Painless The django-sage-painless is a valuable package based on Django Web Framework & Django Rest Framework for high-level and rapid web

sageteam 51 Sep 15, 2022
Wrap the Blockchain API in Django!

django-blockchain Wrap the Blockchain API in Django. Installation pip install django-blockchain Add app in your settings.py INSTALLED_APPS = [ "d

Dmitry Kalinin 2 Feb 04, 2022
Django Audit is a simple Django app that tracks and logs requests to your application.

django-audit Django Audit is a simple Django app that tracks and logs requests to your application. Quick Start Install django-audit pip install dj-au

Oluwafemi Tairu 6 Dec 01, 2022
PEP-484 stubs for django-rest-framework

pep484 stubs for Django REST framework Mypy stubs for DRF 3.12.x. Supports Python 3.6, 3.7, 3.8 and 3.9. Installation pip install djangorestframework-

TypedDjango 303 Dec 27, 2022
A Django GraphQL (Graphene) base template

backend A Django GraphQL (Graphene) base template Make sure your IDE/Editor has Black and EditorConfig plugins installed; and configure it lint file a

Reckonsys 4 May 25, 2022
Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards in settings file paths and mark setti

Nikita Sobolev 940 Jan 03, 2023
Duckiter will Automatically dockerize your Django projects.

Duckiter Duckiter will Automatically dockerize your Django projects. Requirements : - python version : python version 3.6 or upper version - OS :

soroush safari 23 Sep 16, 2021
Send logs to RabbitMQ from Python/Django.

python-logging-rabbitmq Logging handler to ships logs to RabbitMQ. Compatible with Django. Installation Install using pip. pip install python_logging_

Alberto Menendez Romero 38 Nov 17, 2022
Sistema de tratamento e análise de grandes volumes de dados através de técnicas de Data Science

Sistema de tratamento e análise de grandes volumes de dados através de técnicas de data science Todos os scripts, gráficos e relatórios de todas as at

Arthur Quintanilha Neto 1 Sep 05, 2022
Location field and widget for Django. It supports Google Maps, OpenStreetMap and Mapbox

django-location-field Let users pick locations using a map widget and store its latitude and longitude. Stable version: django-location-field==2.1.0 D

Caio Ariede 481 Dec 29, 2022
Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI

martor Martor is a Markdown Editor plugin for Django, supported for Bootstrap & Semantic-UI. Features Live Preview Integrated with Ace Editor Supporte

659 Jan 04, 2023
Pipeline is an asset packaging library for Django.

Pipeline Pipeline is an asset packaging library for Django, providing both CSS and JavaScript concatenation and compression, built-in JavaScript templ

Jazzband 1.4k Jan 03, 2023
This a Django TODO app project and practiced how to deploy and publish the project to Heroku

ToDo App Demo | Project Table of Contents Overview Built With Features How to use Acknowledgements Contact Overview Built With HTML CSS JS Django How

Cetin OGUT 1 Nov 19, 2021
Django-Docker - Django Installation Guide on Docker

Guía de instalación del Framework Django en Docker Introducción: Con esta guía p

Victor manuel torres 3 Dec 02, 2022
PicoStyle - Advance market place website written in django

Advance market place website written in django :) Online fashion store for whole

AminAli Mazarian 26 Sep 10, 2022