S1K4RA / microservices_project

Simple Microservices using Flask, Celery, Redis, and Docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

microservices_project

Simple Microservices Project Using Docker
Default access on http://127.0.0.1:5000/

Explanation

Libraries / Packages used:
Flask - https://flask.palletsprojects.com/en/2.1.x/
Celery - https://docs.celeryq.dev/en/stable/
Redis - https://redis.io/docs/
Elastichsearch - https://www.elastic.co/guide/index.html

This microservices is also deployed on Docker using docker-compose
docker-compose - https://docs.docker.com/compose/

Image used :
MySQL - https://hub.docker.com/_/mysql
phpMyAdmin - https://hub.docker.com/r/phpmyadmin/phpmyadmin/

Features

There are 3 simple microservices written here:

  1. Student Storage
    How to Access : /student
    Page :
    /login
    /logout
    /register
    /paper/upload - Upload File
    /paper/(name) - Look for paper based on filename
    /paper/download/(name) - Download paper based on filename

*Accepted Extensions : pdf

  1. Simple Calculator
    How to Access : /api
    Page :
    /prime/(index) - result of prime n-th
    /prime/palindrome/(index) - result of prime palindrome n-th

  2. Simple Cloud Storage
    How to Access : /cloud
    Page :
    /upload/ - Upload File
    /download/(name) - Download File

*Accepted Extensions : txt, pdf, png, jpg, jpeg, gif

Dependencies

Python pip install gevent pip install -U Celery pip install "celery[redis]" pip install Flask

*See more at requirements.txt

How To Run

Running Without Docker
Warning : Might not work. you need to change a few line of codes.

Install Virtual Environtment
py -3 -m venv venv

Activate venv
venv\Scripts\activate

Initialize Flask
set FLASK_APP=routes.py flask run

activate celery
celery -A tasks worker --loglevel=info -P gevent

*use gevent if on Windows. skip if using Linux

redis for celery
broker, backend : redis://localhost:6379/0

Running With Docker
docker-compose build docker-compose up

redis for celery
broker, backend : redis://redis:6379/0

Elasticsearch

Use code below to re-index
es.indices.delete(index='paper', ignore=[400, 404])
es.create(index='paper', id=1, ignore=400, body=mapping)

About

Simple Microservices using Flask, Celery, Redis, and Docker


Languages

Language:Python 79.2%Language:HTML 20.8%