HUB
Sign inSign up
flask-test logo

nakamasato/flask-test

By nakamasato

•Updated over 5 years ago

Image
0

495

nakamasato/flask-test repository overview

⁠flask sample app

⁠APIs

  1. GET /health
    {"status":"healthy"}
    
  2. GET /users/1
    {
        "id": 1,
        "name": "test_user1"
    }
    
  3. POST /users/
    curl -X POST -H "Content-Type: application/json" -d '{"name": "naka", "email": "[email protected]"}' localhost:5000/users
    {
      "id": 7,
      "name": "naka"
    }
    

⁠Local Development

⁠With Local Python
  1. Run MySQL

    docker-compose -f docker/docker-compose.yml up -d mysql
    
  2. Local env

    python3 -m venv venv
    . venv/bin/activate
    cd src
    pip install -r sample/requirements.txt
    FLASK_APP=sample FLASK_ENV=development flask run
    
  3. Check health

    curl localhost:5000/health
    {"status":"healthy"}
    
  4. Run test

    cd src
    python -m pytest
    ==================================================== test session starts ====================================================
    platform darwin -- Python 3.7.8, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
    rootdir: /Users/masato-naka/repos/nakamasato/flask-test/src
    collected 3 items
    
    tests/test_api.py ...                                                                                                 [100%]
    
    ===================================================== 3 passed in 0.06s =====================================================
    
⁠With Docker
  1. Docker Compose

    docker-compose -f docker/docker-compose.yml up # add --build if you want to rebuild
    
  2. Curl

    curl localhost:5000/health
    {"status":"healthy"}
    
Tag summary
Recent tags
Content type
Image
Digest
Size
333.9 MB
Last updated
over 5 years ago
docker pull nakamasato/flask-test:latest