Easily serve plain JS scripts to the browser with auto-generated HTML.
It will automatically create the HTML page that the JS script will run in, and
will show the console output (using
console.log, etc.) on the page.
var serve =http = ;var src = 'alert("Hello World!");';http;// View in your browser to be alerted
Also with Express:
var express =serve = ;var src = 'alert("Hello World!);';;
Pass the options object as the first argument to the
It will return a function that can be used as a request listener for a server
that will serve the automatically generated HTML and JS code.
The returned function can also be used as Connect middleware.
src option can be either a string, stream, or a function. If it is a
function, it must call the provided callback with an optional error and a string
noConsole argument will disable the console redirection when it is
By default, the generated HTML page will display the output that was printed to
the console with
noConsole is true, this behavior is
Creates an HTTP server that serves the provided JS script to browsers. To make
available globally, install with
npm install -g serve-script.
serve-script [file] [options]
file specifies the JS file to serve. If no file is provided, uses stdin.
-p, --port: The HTTP port to listen on (default 8000).
--no-console: Do not show
console.logoutput on the web page.