Skip to content

Ashu407/java-quotes-app

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Java Motivational Quotes App

This project is a simple Java-based HTTP server that serves random motivational quotes via a REST API. The quotes are externalized to a quotes.txt file for easy customization.

Features

  • Serves random motivational quotes in JSON format.
  • Uses an external quotes.txt file for configurable quotes.
  • Lightweight HTTP server using com.sun.net.httpserver.HttpServer.
  • Dockerized for easy deployment.

Requirements

  • Java 17+
  • Maven (if building from source)
  • Docker (optional, for containerized deployment)

Setup and Usage

Running Locally

  1. Clone the repository:
    git clone https://github.com/LondheShubham153/java-quotes-app.git
    cd java-quotes-app
  2. Ensure quotes.txt exists in the project directory and contains quotes (one per line).
  3. Compile and run the application:
    javac src/Main.java -d out
    java -cp out Main
  4. The server will start on http://localhost:8000/.
  5. Test the API using:
    curl http://localhost:8000/

Running with Docker

  1. Build the Docker image:
    docker build -t motivational-quotes-api .
  2. Run the container:
    docker run -p 8000:8000 motivational-quotes-api
  3. Access the API at http://localhost:8000/.

File Structure

project-root/
│── src/
│   └── Main.java
│── quotes.txt
│── Dockerfile
│── README.md
│── target/
│   └── myapp.jar (if using Maven build)

Customizing Quotes

To customize the quotes, edit quotes.txt and restart the application. Each quote should be on a new line.

License

This project is licensed under the MIT License.

Author

TrainWithShubham

About

docker_prac

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 81.9%
  • Dockerfile 18.1%