Giter Club home page Giter Club logo

jotd's Introduction

Joke of the Day (JOTD) REST API

This is a simple REST API for managing Jokes of the Day (JOTD) built using Python and FastAPI.

Getting Started

Local development

Prerequisites

  • python3.8 or later

For local development, create and activate a virtual environment using:

> python -m venv .venv
> source .venv/bin/activate

Install the dependencies:

(.venv) > pip install -r requirements.txt

Run the development server:

(.venv) > cd src
(.venv) > uvicorn main:app --reload

The API will be available at http://localhost:8000/.

Run with Docker

Assuming you have docker installed, run:

> ./scripts/build_run_local.sh

This will expose the API at http://localhost:8000

Testing

With the API running on port 8000, run the test script:

> ./scripts/test_jotd_api.sh

Endpoints

  • POST /jotd: Create a new JOTD

    request body

    {
        "text": "Why did the tomato turn red? Because it saw the salad dressing!",
        "date": "2022-01-01",
        "description": "A pun about salad"
    }

    response

    {
            "jotd": {
            "id": 1,
            "text": "Why did the tomato turn red? Because it saw the salad dressing!",
            "date": "2022-01-01",
            "description": "A pun about salad"
        }
    }
  • GET /jotd/{id}: Retrieve a specific JOTD by ID

    response

    {
            "jotd": {
            "id": 1,
            "text": "Why did the tomato turn red? Because it saw the salad dressing!",
            "date": "2022-01-01",
            "description": "A pun about salad"
        }
    }
  • GET /jotd/date/{date}: Retrieve a specific JOTD by date

    response

    {
            "jotd": {
            "id": 1,
            "text": "Why did the tomato turn red? Because it saw the salad dressing!",
            "date": "2022-01-01",
            "description": "A pun about salad"
        }
    }
  • PUT /jotd/{id}: Update a specific JOTD by ID

    request body

    {
        "text": "Why did the tomato turn red? Because it saw the salad dressing!",
        "date": "2022-01-01",
        "description": "A pun about salad"
    }

    response

    {
            "jotd": {
            "id": 1,
            "text": "Why did the tomato turn red? Because it saw the salad dressing!",
            "date": "2022-01-01",
            "description": "A pun about salad"
        }
    }
  • DELETE /jotd/{id}: Delete a specific JOTD by ID

    response

    {
        "message": "jotd deleted"
    }

Dependencies

Dev Dependencies

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.