cleoold / open-to-get-random-image

A simple server to let a randomly chosen image show up on the page

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

License: CC0-1.0

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 to server.ts. The folder contains 1.jpg, 2.jpg and so on. In this case run
    ts-node server.ts -d -s ./rresource 
  • There is a file called images.txt in ./rrecource/ which is parallel to server.ts. The file contains:
    https://foo.bar/1.jpg
    https://foo.gar/3.png
    ...
    
    In this case run
    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)

About

A simple server to let a randomly chosen image show up on the page

License:Creative Commons Zero v1.0 Universal


Languages

Language:TypeScript 85.8%Language:HTML 14.2%