Exercise 1 algorithm transformed into an API RESTful.
"Transforme o algoritmo anterior em uma API Rest. Você receberá como parâmetro uma lista com os valores de An e deverá retornar a saída do algoritmo no formato JSON."
- run.sh - shell script to start the application.
- run/activate.sh - shell script to set and/or activate the virtual environment.
- run/run_app.sh - shell script to check/install all required packages and run the application.
- app.py - application's source code.
- list.json - JSON file to be used as input in the application.
- post.sh - shell script to POST
list.json
to the application. - requirements.txt - list of all necessary packages to run the application.
This application is intended for use in Linux based systems with python3
installed.
All packages listed in requirements.txt will be installed upon running the application as instructed below.
After cloning this repository, cd
to ex2
directory and follow the instructions bellow.
1. To start the application (inside virtual environment), run:
$ source run.sh
Note:
- if the virtual environment is not yet set, you'll be prompted to install/update
python3-venv
and avenv
directory will be created.- when running the virtual environment for the first time, you'll be prompted to install all necessary packages to run the application.
2. Edit the list values (inside square brackets) in list.json
as you like.
{
"list": [1, 2, 3]
}
Note: the application only accepts values within the range 0 <= value <= 15.
3. To input this list to the application, in another shell window, run:
$ sh post.sh
The result will be printed on stdout in JSON format (see image bellow).
Note: you can use other ways of posting the
list.json
file, such as Postman, to get the application's result.
4. To kill the application, press ctrl+C
.
5. To deactivate the virtual environment, run:
(venv) $ deactivate