https://github.com/rob-murray/ferver
A Ruby gem to serve files over HTTP, packaged as a Ruby gem
https://github.com/rob-murray/ferver
ruby webserver
Last synced: about 1 year ago
JSON representation
A Ruby gem to serve files over HTTP, packaged as a Ruby gem
- Host: GitHub
- URL: https://github.com/rob-murray/ferver
- Owner: rob-murray
- License: mit
- Created: 2012-09-10T16:52:57.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2021-01-09T20:15:54.000Z (over 5 years ago)
- Last Synced: 2024-10-04T14:37:48.571Z (over 1 year ago)
- Topics: ruby, webserver
- Language: Ruby
- Homepage:
- Size: 113 KB
- Stars: 14
- Watchers: 4
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Ferver = File-Server
#### Ferver: A simple web app to serve files over HTTP packaged as a Ruby gem.
[](https://travis-ci.org/rob-murray/ferver)
[](https://codeclimate.com/github/rob-murray/ferver)
[](https://coveralls.io/github/rob-murray/ferver?branch=master)
[](http://badge.fury.io/rb/ferver)
### Description
This is super, simple ruby gem to serve files over **http**, useful as a basic file server to quickly share files on your local network or something over the web. Just install the gem and go!
Here's the spec for **ferver**:
* available over http
* provide a list of files as html and json
* ignore directories
* ignore dotfiles - turn off with setting
* serve files as individual files
* minimal config
* able to specify the directory to serve files from
### Getting started
Using **ferver** could not be simpler - just install the **ferver** gem.
```bash
$ gem install ferver
```
### Usage
You can run **ferver** from any directory, just pass in the directory you want to serve files from as a command line argument or leave blank to use the current directory.
##### Use the current directory
```bash
$ ferver
````
##### Use a specific directory
For example, to serve files from **/Users/rob/Projects/ferver/** directory pass the path in as below using the `--directory` option.
```bash
$ ferver -d /Users/rob/Projects/ferver/
````
##### Serve all files
By default, dotfiles will be hidden. Use the `--all` option to serve all files.
```bash
$ ferver -a
````
> Note that zero size files will always be hidden.
##### Configure webserver
If required, you can configure the bind address or port number used by the webserver. By default this is `0.0.0.0` and port `4567` which means the server is accessible from outside your machine (if firewall permits). For example if you used the configuration below then it would only be accessible from local machine and on port `9999`.
```bash
$ ferver -p 9999 -b 127.0.0.1
````
##### Command line help
For a list of arguments just use the `--help` switch.
```bash
$ ferver -h
````
### Accessing files
The **ferver** gem uses [Sinatra](http://www.sinatrarb.com/) and runs on default port configuration so just point your browser to `http://localhost:4567` to list the files.
> If you are unable to connect then please check any firewall settings or the configured bind address or port number!
#### HTML
List available files in your browser.
`http://localhost:4567/files`
#### JSON
Requesting content-type `json`, for example passing the header `Accept: application/json` will return the list of files as json.
```bash
curl -i -H "Accept: application/json" http://localhost:4567/files
```
#### Download a file
Files are available via their zero based index in the list, e.g. `http://localhost:4567/files/:id`
For example to download file appearing third in the list displayed earlier, request `http://localhost:4567/files/2`
### Contributions
Please use the GitHub pull-request mechanism to submit contributions.
After cloning the repo, you can run the web application without having to publish and then install the gem package by calling the executable as per normal.
### License
This project is available for use under the MIT software license.
See LICENSE