Simple rest service with Flask by Philipp Wurm phiwu@gmx.at
This service provides a simple rest api with 3 methods:
- GET hello
- /rest/v1/hello
- returns "Hello World".
- /rest/v1/hello
- GET helloUser
- /rest/v1/hello/{name}
- returns "Hello " depending on the username.
- /rest/v1/hello/{name}
- POST randomNumber
- /rest/v1/random
- expects a random range as json in body, e.g.
{"from": 0, "to": 100}
.- returns a random value between from and to.
- GET healthCheck
- /health/ready
- returns a ready message
- /health/ready
- Python 3.7+
- pip3
To start the example in development mode (Linux/Fedora 30):
- open a terminal and install virtualenv
pip3 install virtualenv --user
- in project root create a virtual environment
virtualenv --python=python3 target
(choose another name instead of target if you wish). - enter target directory
cd target
- call
source bin/activate
(The source command can be used to load any functions file into the current shell script or a command prompt.) - install flask inside this virtual environment
pip install flask
(do not use pip3 command, just pip) - return to project root with
cd ..
- run the application
python3 app.py