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.
- Serves random motivational quotes in JSON format.
- Uses an external
quotes.txtfile for configurable quotes. - Lightweight HTTP server using
com.sun.net.httpserver.HttpServer. - Dockerized for easy deployment.
- Java 17+
- Maven (if building from source)
- Docker (optional, for containerized deployment)
- Clone the repository:
git clone https://github.com/LondheShubham153/java-quotes-app.git cd java-quotes-app - Ensure
quotes.txtexists in the project directory and contains quotes (one per line). - Compile and run the application:
javac src/Main.java -d out java -cp out Main
- The server will start on
http://localhost:8000/. - Test the API using:
curl http://localhost:8000/
- Build the Docker image:
docker build -t motivational-quotes-api . - Run the container:
docker run -p 8000:8000 motivational-quotes-api
- Access the API at
http://localhost:8000/.
project-root/
│── src/
│ └── Main.java
│── quotes.txt
│── Dockerfile
│── README.md
│── target/
│ └── myapp.jar (if using Maven build)
To customize the quotes, edit quotes.txt and restart the application. Each quote should be on a new line.
This project is licensed under the MIT License.