Skip to content
Best practices of how to setup a python flask web application or api
Python HTML Shell Dockerfile JavaScript CSS
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea update pycharm configuration Oct 9, 2018
app add api endpoints and update tests and readme Oct 7, 2018
img initial commit Oct 5, 2018
.gitignore initial commit Oct 5, 2018
Dockerfile initial commit Oct 5, 2018
deploy.sh initial commit Oct 5, 2018
readme.md add api endpoints and update tests and readme Oct 7, 2018
requirements.txt update requests library Dec 27, 2018

readme.md

This is the base sceleton for a Python Flask app

To use this sceleton, just

  • fork this repo
  • clone this repo
  • remove the parts not needed

Prerequisites:

  • docker is installed

Steps to run the app locally:

  1. Build the container locally: docker build -t my-flask-app .
  2. Run the container locally: docker run -it --rm -p 80:80 --name my-flask-app -v $(pwd)/app:/app my-flask-app
  3. Access the app via your browser: http://localhost

Testing:

pytest is ran from within the /app directory inside the container on build. The container build will not be successful if a test fails. For the test to be successful the build has to happen within Daimler's internal network and with the certificate in the /app directory.

The following screenshot helps to configure testing in pycharm:

Api Documentation:

Sample API request: GET /api/<string:variable>

This an endpoint of the api.

Endpoint: GET /api/<string:variable>

Return constraints:

{
    "name": String, 
    "data": {
        "age": Int,
        "height": String
    }
}

Return example:

{
    "name": "jonnylangefeld", 
    "data": {
        "age": 27,
        "height": "6 ft 5.5"
}

You can’t perform that action at this time.