Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cleoold/open-to-get-random-image
A simple server to let a randomly chosen image show up on the page
https://github.com/cleoold/open-to-get-random-image
server
Last synced: 25 days ago
JSON representation
A simple server to let a randomly chosen image show up on the page
- Host: GitHub
- URL: https://github.com/cleoold/open-to-get-random-image
- Owner: cleoold
- License: cc0-1.0
- Created: 2020-01-10T00:44:48.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T10:57:11.000Z (over 1 year ago)
- Last Synced: 2023-03-08T07:50:39.711Z (over 1 year ago)
- Topics: server
- Language: TypeScript
- Size: 42 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![License: CC0-1.0](https://img.shields.io/badge/License-CC0%201.0-lightgrey.svg)](http://creativecommons.org/publicdomain/zero/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 ` the source directory/file name provided for above two options#### OPTIONAL OPTION:
`--port -p ` 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
```sh
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
```sh
ts-node server.ts -f -s ./rresource/images.txt
```
Enter `localhost:8080` in the browser and the page will show up.### Install
```sh
npm install
```### Attribution
command-line-args (https://www.npmjs.com/package/command-line-args)
Express (https://www.npmjs.com/package/express)