Skip to content

peshala-prabhapoorna/city_time_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

city_time_api

current time of cities around the world

running the API

  1. create and activate a virtual environment
virtualenv venv
source venv/bin/activate # macOS and Linux
  1. install dependencies
pip3 install -r requirements.txt
  1. run the API (from project root)
fastapi dev src/main.py

routes

  1. GET - /
    this route returns a JSON object with time_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/
  1. 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
  1. 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}'
  1. 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
  1. 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

About

current time of cities around the world

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages