This is a bare-bones example of a task specified in Devsnest's WEB DEV Intro | Python Flask Framework Basics
The entire application is contained within the flaskapi.py
file.
The repo also holds devsnest-flask-api.postman_collection.json
which can be imported as POSTMAN collection
pip3 install -r requirements.txt
python3 flask.py
The REST API to the API app is described below.
GET /add/<your string>
curl -i -H 'Accept: application/json' http://localhost:5000/add/helloworld
HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 2
The string helloworld has been saved in the server!
POST /add
curl -i --header "Content-Type: application/json" --request POST --data '{"string":"helloworld"}' http://localhost:5000/add
HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 201 Created
Connection: close
Content-Type: application/json
Content-Length: 36
The string helloworld has been saved in the server!
GET /concat
curl -i -H 'Accept: application/json' http://localhost:5000/concat
HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 36
helloworld helloworld