Skip to content

This project is a simple RESTful API for fetching random motivational quotes. It uses Flask and Flask-RESTful for API creation and supports CORS for cross-origin requests.

License

Notifications You must be signed in to change notification settings

whdev36/quote-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quote API

This project is a simple RESTful API for fetching random motivational quotes. It uses Flask and Flask-RESTful for API creation and supports CORS for cross-origin requests.


Features

  • Fetch random motivational quotes.
  • Easy integration with other projects.
  • CORS support for cross-origin requests.

Tech Stack

  • Backend: Flask, Flask-RESTful
  • HTTP Requests: requests library
  • Frontend: Bootstrap (for simple UI)

Installation

Follow these steps to run the project locally:

  1. Clone the repository:

    git clone https://github.com/whdev36/quote-api.git
    cd quote-api
  2. Create a virtual environment (optional but recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows, use venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Run the application:

    python app.py
  5. Open your browser and navigate to http://127.0.0.1:5000.


API Endpoints

1. Random Quote

  • Endpoint: /api/random
  • Method: GET
  • Response:
    {
        "content": "The only way to do great work is to love what you do.",
        "author": "Steve Jobs"
    }

2. Home Page

  • Endpoint: /
  • A simple HTML page with instructions on how to use the API.

How to Use the API

Example (JavaScript)

fetch('http://127.0.0.1:5000/api/random')
    .then(response => response.json())
    .then(data => {
        console.log(data.content); // Display the quote
        console.log(data.author);  // Display the author
    })
    .catch(error => console.error('Error:', error));

Notes

  • The API fetches random quotes from https://api.quotable.io/random.
  • If the external API is unreachable, the service returns an error message.

Contributing

Contributions are welcome! If you encounter any issues or have suggestions, feel free to create a pull request or open an issue.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

Created by whdev36. Feel free to reach out!

About

This project is a simple RESTful API for fetching random motivational quotes. It uses Flask and Flask-RESTful for API creation and supports CORS for cross-origin requests.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published