Add the following code to your project's shard.yml under:
to use in production
- OR -
development_dependencies to use in development
Static file server written in Crystal.
alive is a fast, secure, efficient and easy to use static file server. It can both be used as a library and a CLI program. The purpose of alive is to make static website development faster and without a hassle. It follows the Unix philosophy, "do one thing and do it well". Out of the box, alive allows you to customize every option it has.
git clone https://github.com/often/alive.git
crystal build -o alive --release cli.cr
Usage: ./alive [arguments (optional)] -h, --help Displays helpful information. -d <path>, --directory=<path> Set the directory path to serve files from. Default: . -a <address>, --address=<address> Address to listen on. Default: random (127.0.0.x) -p <port>, --port=<port> Port to listen on. Default: random (1-65535) -t, --tls Enable TLS. Default: false -k <path>, --key=<path> Set the private key path. Default: private.key -c <path>, --certificate=<path> Set the certificate chain path. Default: certificate.crt -l, --directory-listing Disable directory listing. Default: true
dependencies: alive: github: often/alive
require "alive" alive # Starts a static file server with all the default options set. alive tls: true, key: "/path/to/private.key", certificate: "/path/to/certificate.crt" # Starts a static file server with TLS enabled. alive directory_listing: false # Starts a static file server with directory listing disabled. # and so on.
If it is a public website you are hosting with alive I recommend that you enable TLS. You can get a free TLS certificate from Let's Encrypt.
You may also generate a self-signed TLS certificate if it is a local development server you are running.
For additional security steps you might want to disable directory listing.
cli.cr you may want to setup an alias in your
.bashrc for ease of access. I did it like so: