Eazytraining - Simple application to show how to query API from webapp

Overview

student-list

Eazytraining - Simple application to show how to query API from webapp

This repo is a simple application to list student with a webserver (PHP) and API (Flask)

project


Objectives

The objectives of this practice exam are to ensure that you are able to manage a docker infrastructure, so you will be evaluated about the following

Themes:

  • improve an existed application deployment process
  • versioning your infrastructure release
  • address best practice when implementing docker infrastructure
  • Infrastructure As Code

Context

POZOS is an IT company located in France and develops software for High School.

The innovation department want to disrupt the existing infrastructure to ensure that

it can be scalable, easily deployed with a maximum of automation.

POZOS wants you to build a POC to show how docker can help you and how much this technology is efficient.

For this POC, POZOS will give you an application and want you to build a "decouple" infrastructure based on Docker.

Currently, the application is running on a single server with any scalability and any high availability.

When POZOS needs to deploy a new release, every time some goes wrong.

In conclusion, POZOS needs agility on its software farm.

Infrastructure

For this POC, you will only use one single machine with a docker installed on it.

The build and the deployment will be made on this machine.

POZOS recommends you to use centos7.6 OS because it's the most used in the company.

Please also note that you are authorized to use a virtual machine base on Centos7.6 and not your physical machine.

The security is a very critical aspect of POZOS DSI so please do not disable the firewall or other security mechanisms otherwise please explain your reasons in your delivery.

Application

The application that you will be working on is named "student_list", this application is very basic and enables POZOS to show the list of the student with their age.

student_list has two modules:

  • the first module is a REST API (with basic authentication needed) who send the desire list of the student based on JSON file
  • The second module is a web app written in HTML + PHP who enable end-user to get a list of students

Your work is to build one container for each module an make them interact with each other

Application source code can be found here

The files that you must provide (in your delivery) are Dockerfile and docker-compose.yml (currently both are empty)

Now it is time to explain you each file's role:

  • docker-compose.yml: to launch the application (API and web app)
  • Dockerfile: the file that will be used to build the API image (details will be given)
  • student_age.json: contain student name with age on JSON format
  • student_age.py: contains the source code of the API in python
  • index.php: PHP  page where end-user will be connected to interact with the service to - list students with age. You need to update the following line before running the website container to make api_ip_or_name and port fit your deployment $url = 'http:// /pozos/api/v1.0/get_student_ages';

Build and test (7 points)

POZOS will give you information to build the API container

  • Base image

To build API image you must use "python:2.7-stretch"

  • Maintainer

Please don't forget to specify the maintainer information

  • Add the source code

You need to copy the source code of the API in the container at the root "/" path

  • Prerequisite

The API is using FLASK engine,  here is a list of the package you need to install

apt-get update -y && apt-get install python-dev python3-dev libsasl2-dev python-dev libldap2-dev libssl-dev -y
pip install flask==1.1.2 flask_httpauth==4.1.0 flask_simpleldap python-dotenv==0.14.0
  • Persistent data (volume)

Create data folder at the root "/" where data will be stored and declare it as a volume

You will use this folder to mount student list

  • API Port

To interact with this API expose 5000 port

  • CMD

When container start, it must run the student_age.py (copied at step 4), so it should be something like

CMD [ "python", "./student_age.py" ]

Build your image and try to run it (don't forget to mount student_age.json file at /data/student_age.json in the container), check logs and verify that the container is listening and is  ready to answer

Run this command to make sure that the API correctly responding (take a screenshot for delivery purpose)

curl -u toto:python -X GET http:// : /pozos/api/v1.0/get_student_ages

Congratulation! Now you are ready for the next step (docker-compose.yml)

Infrastructure As Code (5 points)

After testing your API image, you need to put all together and deploy it, using docker-compose.

The docker-compose.yml file will deploy two services :

  • website: the end-user interface with the following characteristics
    • image: php:apache   - environment: you will provide the USERNAME and PASSWORD to enable the web app to access the API through authentication
    • volumes: to avoid php:apache image run with the default website, we will bind the website given by POZOS to use. You must have something like ./website:/var/www/html
    • depend on: you need to make sure that the API will start first before the website
    • port: do not forget to expose the port
  • API: the image builded before should be used with the following specification
    • image: the name of the image builded previously   - volumes: You will mount student_age.json file in /data/student_age.json
    • port: don't forget to expose the port

Delete your previous created container

Run your docker-compose.yml

Finally, reach your website and click on the bouton "List Student"

If the list of the student appears, you are successfully dockerizing the POZOS application! Congratulation (make a screenshot)

Docker Registry (4 points)

POZOS need you to deploy a private registry and store the built images

So you need to deploy :

Or you can use Portus to run both

Don't forget to push your image on your private registry and show them in your delivery.

Delivery (4 points)

Your delivery must be zip named firstname.zip (replace firstname by your own) that contain:

  • A doc or PDF file with your screenshots and explanations.
  • Configuration files used to realize the graded exercise (docker-compose.yml and Dockerfile).

Your delivery will be evaluated on:

  • Explanations quality
  • Screenshots quality (relevance, visibility)
  • Presentation quality

Send your delivery at [email protected] and we will provide you the link of the solution.

good luck

You might also like...
Estudo e desenvolvimento de uma API REST

Estudo e desenvolvimento de uma API REST 🧑‍💻 Tecnologias Esse projeto utilizará as seguintes tecnologias: Git Python Flask DBeaver Vscode SQLite 🎯

Um aplicativo de usuários feito em Django REST Framework, nesse aplicativo eu modifiquei o modelo padrão de user do Django, adicionando campos personalizados e login com email e senha, também desenvolvi funcionalidades para a API e testes automatizados, para conferir tudo leia o README abaixo! RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.
RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

JSON:API support for Django REST framework

JSON:API and Django REST framework Overview JSON:API support for Django REST framework Documentation: https://django-rest-framework-json-api.readthedo

Django-rest-auth provides a set of REST API endpoints for Authentication and Registration

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)

One package to access multiple different data sources through their respective API platforms.

BESTLab Platform One package to access multiple different data sources through their respective API platforms. Usage HOBO Platform See hobo_example.py

A Django-powered API with various utility apps / endpoints.
A Django-powered API with various utility apps / endpoints.

A Django-powered API Includes various utility apps / endpoints. Demos These web apps provide a frontend to the APIs in this project. Issue API Explore

REST API with Flask. No data persistence.
REST API with Flask. No data persistence.

Flask REST API Python 3.9.7 The Flask experience, without data persistence :D First, to install all dependencies: python -m pip install -r requirement

BloodDonors: Built using Django REST Framework for the API backend and React for the frontend
BloodDonors: Built using Django REST Framework for the API backend and React for the frontend

BloodDonors By Daniel Yuan, Alex Tian, Aaron Pan, Jennifer Yuan As the pandemic raged, one of the side effects was an urgent shortage of blood donatio

Releases(v1.0)
Owner
⚡Christophe FREIJANES
Administrateur Systèmes - Enthousiaste - DevOps / SRE 🚀
⚡Christophe FREIJANES
Browsable web APIs for Flask.

Flask API Browsable web APIs for Flask. Status: This project is in maintenance mode. The original author (Tom Christie) has shifted his focus to API S

Flask API 1.3k Dec 27, 2022
simple api build with django rest framework

Django Rest API django-rest-framework Employees management simple API in this project wrote test suites for endpoints wrote simple doc string for clas

OMAR.A 1 Mar 31, 2022
Eureka is a Rest-API framework scraper based on FastAPI for cleaning and organizing data, designed for the Eureka by Turing project of the National University of Colombia

Eureka is a Rest-API framework scraper based on FastAPI for cleaning and organizing data, designed for the Eureka by Turing project of the National University of Colombia

Julian Camilo Velandia 3 May 04, 2022
Restful API framework wrapped around MongoEngine

Flask-MongoRest A Restful API framework wrapped around MongoEngine. Setup from flask import Flask from flask_mongoengine import MongoEngine from flask

Close 525 Jan 01, 2023
Flask RestAPI Project - Transimage Rest API For Python

[ 이미지 변환 플라스크 Rest API ver01 ] 0. Flask Rest API - in SunnyWeb : 이미지 변환 웹의 Flask

OliverKim 1 Jan 12, 2022
REST API framework designed for human beings

Eve Eve is an open source Python REST API framework designed for human beings. It allows to effortlessly build and deploy highly customizable, fully f

eve 6.6k Jan 04, 2023
Automatically generate a RESTful API service for your legacy database. No code required!

sandman2 sandman2 documentation [ ~ Dependencies scanned by PyUp.io ~ ] sandman2 automagically generates a RESTful API service from your existing data

Jeff Knupp 1.9k Jan 07, 2023
Sanic-RESTPlus is an extension for Sanic that adds support for quickly building REST APIs.

Sanic RestPlus Sanic-RESTPlus is an extension for Sanic that adds support for quickly building REST APIs. Sanic-RESTPlus encourages best practices wit

Ashley Sommer 106 Oct 14, 2022
Transparently use webpack with django

Looking for maintainers This repository is unmaintained as I don't have any free time to dedicate to this effort. If you or your organisation are heav

2.4k Dec 24, 2022
FastAPI framework, high performance, easy to learn, fast to code, ready for production

FastAPI framework, high performance, easy to learn, fast to code, ready for production Documentation: https://fastapi.tiangolo.com Source Code: https:

Sebastián Ramírez 53.1k Jan 06, 2023
Django-rest-auth provides a set of REST API endpoints for Authentication and Registration

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST

Tivix 2.4k Dec 29, 2022
A small repository of projects built in my course, REST APIs with Flask and Python.

A small repository of projects built in my course, REST APIs with Flask and Python.

Teclado 1k Jan 05, 2023
Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

💨 Fast, Async-ready, Openapi, type hints based framework for building APIs

Vitaliy Kucheryaviy 3.8k Jan 04, 2023
Estudo e desenvolvimento de uma API REST

Estudo e desenvolvimento de uma API REST 🧑‍💻 Tecnologias Esse projeto utilizará as seguintes tecnologias: Git Python Flask DBeaver Vscode SQLite 🎯

Deusimar 7 May 30, 2022
Web APIs for Django. 🎸

Django REST framework Awesome web-browsable Web APIs. Full documentation for the project is available at https://www.django-rest-framework.org/. Fundi

Encode 24.7k Jan 04, 2023
Integrate GraphQL into your Django project.

Graphene-Django A Django integration for Graphene. 💬 Join the community on Slack Documentation Visit the documentation to get started! Quickstart For

GraphQL Python 4k Dec 31, 2022
A small project in Python + Flask to demonstrate how to create a REST API

SmartBed-RESTApi-Example This application is an example of how to build a REST API. The application os a mock IoT device, simulating a Smart Bed. Impl

Rares Cristea 6 Jan 28, 2022
Simple Crud Api With Django Rest Framework

SIMPLE CRUD API WITH DJANGO REST FRAMEWORK Django REST framework is a powerful and flexible toolkit for building Web APIs. Requirements Python 3.6 Dja

kibet hillary 1 May 03, 2022
Authentication Module for django rest auth

django-rest-knox Authentication Module for django rest auth Knox provides easy to use authentication for Django REST Framework The aim is to allow for

James McMahon 873 Dec 30, 2022