Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 2.29 KB

readme.md

File metadata and controls

66 lines (45 loc) · 2.29 KB

In development FastAPI BeautifulSoup requests webdriver_manager

Temperature API

This is an API that retrieves the current temperature of cities around the world. The API uses the Time and Date website to get weather information.

Technologies Used

  • FastAPI: Web framework for creating the API.
  • BeautifulSoup: For parsing and extracting data from HTML pages.
  • requests: For making HTTP requests.

Features

  • /all/countries: Returns a list of all available countries for queries.
  • /all/cities: Returns a list of all available cities for queries.
  • /{country}/{city}: Returns the current temperature of the specified city in the specified country.

Installation

Clone this repository and install the dependencies:

git clone https://github.com/pedrohcleal/timeAPI.git
cd timeAPI
pip install -r requirements.txt

Usage

  1. Update Cities: To update the list of available cities, run the handler.py script. This will use Selenium to collect data from Time and Date.

    python handler.py
  2. Run the FastAPI Server: To start the API server, run the following command:

    uvicorn main:app --reload

    The server will be available at http://127.0.0.1:8000.

Project Structure

  • handler.py: Contains functions for collecting and processing city and temperature data.
  • main.py: Defines the API endpoints using FastAPI.
  • crud.py: Helper functions for text sanitization and data saving.

Dependencies

Make sure to keep the requirements.txt file updated with all the necessary libraries. The requirements.txt file can be generated with:

pip freeze > requirements.txt

Contribution

If you would like to contribute to the project, feel free to submit pull requests. For issues or questions, open an issue on GitHub.