Git Product home page Git Product logo

feature_flags_workshop's Introduction

Weather API

This is a simple Flask application that provides an API endpoint to fetch the temperature of a city from OpenWeatherMap. The application can be Dockerized for easy deployment.

Getting Started

Prerequisites

Installation

git clone https://github.com/yourusername/weather-api.git

OpenWeatherMap API Key

  1. Visit OpenWeatherMap and sign up for an account.
  2. Obtain your API key from the dashboard.

Build and Run

docker build -t weather-api .
docker run -p 5000:5000 -e OPENWEATHER_API_KEY=<your_openweather_api_key> weather-api

Replace <your_openweather_api_key> with your actual OpenWeatherMap API key.

Usage

Access the API endpoint at http://localhost:5000/temperature.

API Endpoint

  • Endpoint: /temperature
  • Method: GET
  • Parameters:
    • city (required): Name of the city.
    • units (optional): Temperature units (imperial or metric). Defaults to metric.
Example Request:
curl http://localhost:5000/temperature?city=London&units=metric
Example Response:
{
  "city": "London",
  "temperature": 20.5,
  "units": "metric"
}

Testing the API with the provided script

Running the Test Script

To test your Weather API endpoint with the provided script, use the following command:

python test_script.py --endpoint http://your-api-endpoint/temperature # This will default to localhost if you don't specify, so only add if necessary

Example Output

City           Metric    Imperial
New York       20.30     68.50
Los Angeles    24.00     75.20
Houston        26.70     80.10
London         14.90     58.90
Hong Kong      25.60     78.10

feature_flags_workshop's People

Contributors

chrisjws-harness avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.