8000 GitHub - toubar/flask-app
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

toubar/flask-app

Repository files navigation

Flask App

Table of Contents

  1. Get up and running
  2. Curl Samples
  3. Running tests

Get up and running

Docker

1- Spin up backend docker container by running:

$ docker-compose up

2- Navigate API using Swagger UI by visiting the URL below

http://localhost:5000/swagger/

Manually

  1. clone this repo
$ git clone https://github.com/toubar/flask-app backend
  1. create python virtual environement
$ python -m venv venv
  1. install dependencies
$ venv/bin/pip install -r requirements.txt
  1. activate virtualenv
$ source venv/bin/activate
  1. add Flask env variables
$ export FLASK_APP="main.py"
$ export FLASK_ENV="development"
$ export FLASK_DEBUG=True
  1. spin up flask server
$ venv/bin/python -m flask run

Curl Samples

GET Services

curl --request GET \
  --url http://127.0.0.1:5000/service

POST Auth (for JWT token)

curl --request POST \
  --url http://127.0.0.1:5000/authenticate \
  --header 'authorization: Bearer undefined' \
  --header 'content-type: application/json' \
  --data '{
	  "jwt_secret": "jwt_secret"
}'

PUT Service (new) -- get JWT token from Auth endpoint

curl --request PUT \
  --url http://127.0.0.1:5000/services \
  --header 'authorization: Bearer <<<PUT JWT TOKEN HERE>>>' \
  --header 'content-type: application/json' \
  --data '{
	  "service": "New Service",
    "ip": "10.12.99.264",
    "servers": [
        {
            "name": "lin-brn-891",
            "status": "running"
        },
        {
            "name": "lin-brn-125",
            "status": "error"
        },
        {
            "name": "lin-brn-711",
            "status": "running"
        },
        {
            "name": "lin-brn-999",
            "status": "running"
        }
    ]
}'

Running tests

assuming venv is activated...

$ cd services/tests 
# run tests
$ python -m pytest 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0