At a customer we are building lots of microservices with Spring boot which runs on Pivotal Cloud Foundry hosted at the Azure platform.
Some of these microservices are called from web pages with certain specific information, like field info.
So in our projects we have most of the time a test html page to mimic the actual behavior.
NodeJS http-server to the rescue
there is a very nice NPM package, http-server, to host this test page with a minimal of effort
Easiest way is to install it globally by the following command in a command line.
[dropshadowbox align=”none” effect=”lifted-both” width=”auto” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ]npm install http-server -g[/dropshadowbox]
Now you can use it everywhere.
Next step is to go to the directory in the command line, where the test page is located.
There fire the commando
[dropshadowbox align=”none” effect=”lifted-both” width=”auto” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ]http-server[/dropshadowbox]
In the command line you will see the http server starting and on which port the page is available
Great tip Frank!
Many people have node/npm installed on their system and it’s easy to have development tooling installed from npm. I generally use the http-server package when *all I need* is a simple server, but I have a couple others installed globally for a similar local dev purpose, but with some added niceties. Here are the two I think are worthy of mention:
– serve: more of a direct alternative to http-server, it brings some capabilities such as ability to set basic auth via environment variables, has a directory navigation for directories without an index.html. It also copies the localhost with port to your clipboard once you’ve executed it, making it pretty simple. http://npm.im/serve
– lite-server: a pre-configured version of browser-sync, bringing with it all of browser-sync’s superpowers for monitoring connections and live-reloads on watched file save changes. Advanced configurations of browser-sync options, such as making use of proxies, can be storied into a standardized name space (bs-config.json) for easy storage in your project repo. http://npm.im/lite-browser
Thanks for the information. Good to know the alternatives
Yup, I’m using http-server in my tooling also. We run it locally with the watch option enabled as we develop. Then when a file is changed we get an automatic refresh of the browser that is connected. Working this way using Domino as a data store, we do need to configure CORS on our development servers. But honestly this isn’t an issue as those are on our local machines also.