Giter Club home page Giter Club logo

td_restapi's Introduction

TD_RESTAPI

A RESTful API built with FastAPI and MongoDB.

Features, stack

  • Python, with FastAPI and pymongo library
  • MongoDB, as database
  • Docker, for deployment

API Usage

  1. Clone the repository
  2. Start the server :
$ docker-compose up -d
  1. Go to localhost:3000/docs

td_restapi's People

Contributors

jofresh avatar

Watchers

 avatar

td_restapi's Issues

exercise-4-json

Modifiez votre API pour que celle-ci fonctionne avec un stockage des données basé sur un fichier json et non plus une base de données. Pour vous aider, vous pourriez utiliser les appels suivant :

import json
def read_json(json_path):
  with open(json_path, "r") as f:
    return json.loads(f.read())
def write_json(json_path, data):
  with open(json_path, "w") as f:
    json.dupmp(data, f, indent=4)

Modifiez votre docker compose pour pouvoir livrer votre nouvelle version

exercise-1-eggs-api

Faites une API Rest avec FASTAPI qui accède à une base de donnée mongodb afin de fournir les endpoits suivants :

  • [GET] eggs
  • [POST] eggs
  • [GET] eggs/immatriculation
  • [DELETE] eggs/immatriculation
  • [UPDATE] eggs/immatriculation

Le modèle utilisé, nommé ModelEgg, doit être composé d'un élevage (origine de l'oeuf), d'une couleur (gris, brun, blanc) et d'une immatriculation (cf. TD Docker). Dans le cas de l'endpoint [POST] eggs, assurez vous qu'une HTTPException soit retournée lorsque l'immatriculation fournie est déjà enregistrée.

Indications : vous utiliserez deux conteneurs, le premier remplira une base de donnée (cf. TD Docker), le second exposera l'API Rest sur le port 3000. Il est attendu que votre modèle soit défini dans un fichier model_egg.py, que votre application RestAPI soit définie dans un fichier app.py, et que la logique associée au parsing d'immatriculation soit contenue dans un fichier immat_parser.py.

Note : utilisez des validator pour vous assurer que l'immatriculation et la couleur du modèle sont valides (https://pydantic-docs.helpmanual.io/usage/validators/).

exercise-2-egg-parameters

Retravaillez l'endpoint [GET] eggs/immatriculation pour qu'il affiche plus d'informations. Celui-ci devra permettre d'afficher (si spécifié) les informations suivantes :

  • numéro d'identification de l'oeuf;
  • le poids de l'oeuf;
  • le pays d'origine de l'oeuf;
  • le jour de ponte;
  • le mois de ponte.

Etendez l'endpoint [POST] eggs pour que celui-ci n'accepte que des oeufs de poids supérieur à 60g qui ne sont pas pondus un jour pair.

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.