Coder Social home page Coder Social logo

co2-fastapi's Introduction

CO2 Emissions FastAPI Project

This project is a FastAPI-based RESTful API that provides data on countries' CO2 emissions, yearly changes, per capita emissions, and life expectancy.

Overview

The project consists of the following main components:

  • FastAPI: A modern Python web framework for building APIs.
  • pandas: A data manipulation and analysis library used to process the CSV data.

The API provides the following endpoints:

  • /: A simple "Hello, World" endpoint.
  • /top10: Returns the top 10 countries with the highest per capita CO2 emissions.
  • /emissions: Accepts a list of country codes and returns the CO2 emissions and yearly change for each country.
  • /top10-life-expectancy: Returns the top 10 countries with the highest life expectancy.
  • /total-emissions: Accepts a list of country codes and returns the total CO2 emissions for the specified countries.

How to Run

  1. Install the required packages:
pip install fastapi uvicorn pandas

Run the FastAPI application:

uvicorn main:app --reload

Visit the default FastAPI documentation at http://127.0.0.1:8000/docs to interact with the API.

How to Test

Install the required testing packages:

pip install fastapi[testing] pytest

Run the tests using pytest:

pytest

pytest will discover and run the test functions in the main_test.py file.

Fly

https://co2-emissions-app.fly.dev/docs

co2-fastapi's People

Contributors

fenglinnorway avatar

Watchers

James Cloos avatar  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.