Test API

This is a template project to highlight how new APIs can be deployed

It supports the following routes

return_sum

Will return the sum of variable "a" and "b". The variables will be cast to float before adding them up.

Parameters:

Name Content
"a" string, representing integer or floating point value (e.g. "3.14")
"b" string, representing integer or floating point value (e.g. "3.14")

Examples

curl

curl -L -H"Content-Type: application/json" -d '{"a":"1","b":"2"}' https://test.space01.phys.ethz.ch/return_sum

Python

import requests
import json

url = "https://test.space01.phys.ethz.ch/return_sum"

headers = {
    "Content-Type": "application/json"
}

data = {
    "a": "1",
    "b": "2",
}

response = requests.post(url, headers=headers, data=json.dumps(data))

if response.status_code == 200:
    print("Request was successful")
    print(response.text)
else:
    print(f"Request failed with status code {response.status_code}")