Git Product home page Git Product logo

inspo-quotes-api's Introduction

🎆 Inspo Quotes API

An API for inspirational quotes, built with FastAPI and SQLAlchemy.

With this API, you can fetch quotes, add them, update them and delete them.

Python FastAPI Docker

🐳 Setup and Run (Docker)

sudo docker build -t inspo_quotes_api ./

sudo docker run -p 80:80 inspo_quotes_api

🔨 Setup (Manual)

This program requires Python 3.10.

Init

python3 -m venv venv

source ./venv/bin/activate
pip install -r requirements.txt
python3 init_db.py

Running

To run this in a dev environment:

source ./venv/bin/activate
uvicorn main:app --reload

API response format

The default response format for all the GET requests is plain text, but you can provide another HTTP Accept header to modify the response format.

Available Accept headers:

  • text/plain - Plain text response (default)
  • application/json - JSON response

➡️ API endpoints

GET /

Fetch a random inspirational quote.

$ curl 127.0.0.1:8000/

{
  "id": 3,
  "quote": "I have not failed. I've just found 10,000 ways that won't work.",
  "status": 200
}

GET /q/<quote_id>

Fetch a specific quote.

$ curl 127.0.0.1:8000/q/5

{
    "id": 5,
    "quote": "Everything you can imagine is real.",
    "status": 200
}

POST /add

Add a new quote. You will get the ID of the quote through the JSON response. The max quote length is 100 characters.

$ curl 127.0.0.1:8000/add -X POST -H "Content-Type: application/json" -d '{ "text": "You miss all the shots you don'\''t take." }'

{
    "id": 10,
    "status": 200
}

POST /update

Update a quote by ID with new text.

$ curl 127.0.0.1:8000/update -X POST -H "Content-Type: application/json" -d '{ "id": 6, "text": "When you have a dream, you'\''ve got to grab it and never let go." }'

{
    "status": 200
}

POST /delete

Delete a quote by ID.

$ curl -X POST 127.0.0.1:8000/delete -H "Content-Type: application/json" -d '{ "id": 7 }'

{
    "status": 200
}

📄 License

This program is licensed under the MIT license.

inspo-quotes-api's People

Contributors

angelofallars avatar

Watchers

 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.