Wednesday, December 6, 2017

Mini-http-server for local Angular JS & other framework web development

In this article I'll introduce to you one of my newest app called mini-http-server. I developed it for myself first, but then I make it open source through GitHub for helping other Angular JS ( or other JS framework) developers.
So first of all, what is Mini-http-server? What is the benefits of using this app instead of using the other million? It's a small, Java based application, which could run in HTTP or HTTPS mode as well. It's really only for local web development. You don't have to install tons of other modules, because it's really only for publishing a specific folder. The app is a JAR file, so it's platform independent, you can run it on Windows, Linux and Max OS as well.

Let's see the installation! Open your web browser and go to the GitHub project site https://github.com/szrnka-peter/mini-http-server/releases. Download the JAR file and the related config.properties file, and additionally the run.bat file if you need it. Open the config, and customize it for your needs.

HTTP

It'll be enough to fill the first 3 parameters:
  • server.type: HTTP in the current case
  • server.port: For example: 8080, 8081, or whatever you want.
  • www.dir: The directory, where your files are located.
Ok, save it, then run the JAR file with the following command:
java -jar mini-https-server.jar
(For Windows users, it's a great idea to put this in a .bat file for easier use.)

If you did everything well, you can see the following screen:

HTTPS

This mode is a bit more difficult. First, modify the server type to "HTTPS". Additionally, in HTTPS mode you must provide a keystore (jks file) for the server. There are many tutorials on the web how to create a keystore:
https://stackoverflow.com/questions/37488090/create-keystore-file-with-one-command

To configure the keystore, you must add the upcoming parameters.
  • keystore.location: Keystore file location
  • keystore.password: Base64 encoded keystore password
  • truststore.location: Truststore file location (same as keystore file)
  • truststore.password: Base64 encoded truststore password
  • password.encrypttype: Encryption type (currently only base64 allowed)
For encoding your password, you should use https://www.base64encode.org/ Copy and paste your bcreated string into the property file. Run the JAR file with the following command:
java -jar mini-https-server.jar
(For Windows users, it's a great idea to put this in a .bat file for easier use.)

If you did everything well, you can see the following screen:

And we're done!

Configure and use VSCode for Java web development

Embarking on Java web development often starts with choosing the right tools that streamline the coding process while enhancing productivity...