Skip to content

Instantly share code, notes, and snippets.

@gbolo
Created April 13, 2022 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbolo/e1c4fc13b13d8b7ec22876e46228eed9 to your computer and use it in GitHub Desktop.
Save gbolo/e1c4fc13b13d8b7ec22876e46228eed9 to your computer and use it in GitHub Desktop.
Small API Server Challenge

Summary

You have been tasked with creating a simple REST API server to help with a monitoring effort. The main purpose of the server is to return information about a website's performance. Details of the three endpoints that this server should have are below.

NOTE you may use any programming language of your choice

Endpoints

request: GET /api/ping

response: json response with current time. see below

{
  "pong": "2021-04-16 10:24:23.118556"
}

request: GET /api/info

response: json response with some server info. see below

{
  "hostname": "interview-1", // this is the hostname of the server
  "uptime": "up 1 minute", // this is the server's uptime
  "load_average": [ 0.18, 0.14, 0.05 ] // this is the cpu load average of the server
}

request: GET /api/crawl/<url>

response: json response with some information about the endpoint

{
  "url": "http://date.jsontest.com", // this is the URL provided in the request path
  "status_code": 200, // this is the response code from the url
  "date_header": "Wed, 13 Apr 2022 12:49:34 GMT", // this is the "Date" header from the http response
  "processing_time_ms": 400 // this is the amount of time in ms it took complete this request
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment