Random image displayer
A simple server to let a randomly chosen image show up on the page when requested. The image pool can be either provided locally in a folder or by URIs.
Usage:
MODE OPTIONS (CHOOSE ONE FROM TWO):
--directory -d
will serve every image in the directory
--file -d
the file contains URIs to the image, separated by lines. will serve images targeted by links contained in the file
REQUIRED OPTION:
--source-path -s <name>
the source directory/file name provided for above two options
OPTIONAL OPTION:
--port -p <number>
specifies a port number. default 8080
Example
- There is a folder called
rresource
parallel toserver.ts
. The folder contains1.jpg
,2.jpg
and so on. In this case runts-node server.ts -d -s ./rresource
- There is a file called
images.txt
in./rrecource/
which is parallel toserver.ts
. The file contains:In this case runhttps://foo.bar/1.jpg https://foo.gar/3.png ...
ts-node server.ts -f -s ./rresource/images.txt
Enter localhost:8080
in the browser and the page will show up.
Install
npm install
Attribution
command-line-args (https://www.npmjs.com/package/command-line-args)
Express (https://www.npmjs.com/package/express)