current time of cities around the world
- create and activate a virtual environment
virtualenv venv
source venv/bin/activate # macOS and Linux
- install dependencies
pip3 install -r requirements.txt
- run the API (from project root)
fastapi dev src/main.py
- GET -
/
this route returns a JSON object withtime_format
,hours
,minutes
,
seconds
keys. time format is 'utc' and other files contain current time in
utc format.
test:
curl -X GET http://localhost:8000/
- GET -
/tz/{city}
this route returns a JSON object with information related to time and
location of the requested location in the {city} path parameter. test:
curl -X GET http://localhost:8000/tz/Colombo
- POST -
/city/
this route returns imformation about the nearest city in JSON format to the
location specified with latitude and longtide inputs. test:
curl -X POST http://localhost:8000/city/ -H "Content-Type: application/json" -d '{"latitude": 6.927503832976636, "longitude": 79.85828762914382}'
- GET -
/gap/
this route returns the time gap between two cities in the request in JSON
format.
test:
curl -X GET http://localhost:8000/gap/?Colombo&Tokyo
- POST -
/add/
add locations to the database using this route.
test:
curl -X POST http://localhost:8000/add/ -H "Content-Type: application/json" -d '{"country": "Sri Lanka", "city": "Colombo", "name": "Lotus Tower", "latitude": 6.927503832976636, "longitude": 79.85828762914382, "description": "a big ol tower"}'
this program was developed using CPython 3.12.3.final.0