Giter Site home page Giter Site logo

dockerized-flask-demo's Introduction

Dockerized Flask Demo

We use docker-compose to launch two containers: flask app exposed behing wsgi server (app) and nginx reverse proxy (nginx).

nginx is exposed at port 80 and wsgi is being 8080.

The app:

We have a basic flask app which exposes one end point ("/") that accepts both GET and POST. If Accept header is set as text/html, then <p>Hello, World</p> is returned. If its set as application/json then json {"message": "Good morning"} is returned. Furthermore, while processing POST, if server finds SERVER_MODE environment variable set as truth (1, True, true etc), then this request is logged in plaingrid.log in /app directory.

Tests:

Within app, we have test-unit.py that have unit tests for the app. You may run python test-unit.py to run all units tests (by mocking endpoints). We also have ./test-smoke that uses curl to fetch data from endpoint and prints to stdout. You can only use ./test-smoke when we have containers running.

How to:

Run these commands:

git clone https://github.com/hasanatkazmi/dockerized-flask-demo.git
cd dockerized-flask-demo
docker-compose build
docker-compose up

Now run ./test-smoke in app directory to see if things are running correctly.

You can modify app/Dockerfile and remove ENV SERVER_MODE=1 and build and run containers again and run smoke test again to ensure that logging functionality is also working as intended.

dockerized-flask-demo's People

Watchers

Hasanat Kazmi avatar  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.