/http-server

An HTTP server written in Java (8th Light project)

Primary LanguageJava

HTTP Server

A project that implements a basic HTTP server, built using Java. It's meant to serve up both static and dynamic websites. The behavior of the server is verified using Cob Spec (see Run Acceptance Tests section below).

Getting Started

Clone this repository to your local machine
$ git clone https://github.com/bean00/http-server.git
$ cd http-server

Dependencies

  1. Java 1.8
  2. JUnit 5.0
  3. Maven

Run Tests

Run the following command to run the unit tests:
$ mvn test

Run Acceptance Tests

The acceptance test and instructions to run them can be found here

Compile and Build Package

At the root dir run the command:
$ mvn package

Run the Server

  • Run the command below from the root directory
  • Pass in a flag and an argument for the directory to serve files from ([-d DIRECTORY])
  • Pass in an *optional flag and argument for the port to listen on ([-p PORT])
    • *The default port is 5000
  • You can enter the arguments in any order

Proper usage:
$ java -jar [SERVER JAR FILE] [-d DIRECTORY]
$ java -jar [SERVER JAR FILE] [-p PORT] [-d DIRECTORY]
Example:
$ java -jar target/http-server-1.0-SNAPSHOT-jar-with-dependencies.jar -d public
$ java -jar target/http-server-1.0-SNAPSHOT-jar-with-dependencies.jar -p 8080 -d public