Coder Social home page Coder Social logo

flask-test-app's Introduction

Flask Sample App

Pre-requisite

To run locally application, install docker and docker compose.

Run docker compose up -d to start app.

Check the following endpoints:

$ curl localhost:8080/-/healthy -w "%{http_code}"
{}
200
$ curl localhost:8080/-/ready -w "%{http_code}"
{}
200
$ curl localhost:8080/user -w "%{http_code}"
[...]
200

Architecture & Command lines

Application is made of:

  • a Web Server for API Calls. The web server can be started with flask run --host 0.0.0.0 --port 8080
  • migration script to confugure the database. The migration script can be run with flask db upgrade

Application needs a PostgreSQL database to run.

Configuration

The following environment variable allow to configure application:

  • POSTGRES_USERNAME: username of PostgreSQL
  • POSTGRES_PASSWORD: password of PostgreSQL
  • POSTGRES_HOST: hostname or IP of PostgreSQL
  • POSTGRES_PORT: listening port of PostgreSQL
  • POSTGRES_DATABASE: name of the database

Endpoints

The following endpoints are available

  • GET localhost:8080/-/healthy: return 200 when server is up
  • GET localhost:8080/-/ready: return 200 when server is up
  • GET localhost:8080/user: return list of users in database
  • POST localhost:8080/user: create a user in database. The request must contain a body: {'username': 'my_username', 'email': 'my_email'}

To Do & Questions

Build

  • Create a GitLab CI pipeline that build the docker image.
  • Suggest improvement of this pipeline.
  • Suggest optimizations on the Dockerfile

Deployment

  • Create Helm chart templates to deploy application
    • A minimum of 2 pods are required for web server
    • don't forget to run migration scripts at deployment
    • After installation, the endpoint /user works well.
  • Are liveness & readiness probes correctly implemented? Why?
  • What improvement can be done in your Helm Chart?

flask-test-app's People

Contributors

ferios08 avatar

Watchers

 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.