Self-hosted, url-based redirection service
Find a file
Armin Friedl 26a79d15b4
All checks were successful
continuous-integration/drone/push Build is passing
Configurable keylen, rename SNIP_FLASK_SECRET
- Length of snipped url is now configurable via `SNIP_KEYLEN` SNIP_FLASK_SECRET
- is renamed to SNIP_SECRET as it is also used internally in snip, not just
  flask
2020-11-09 12:01:14 +01:00
snip Configurable keylen, rename SNIP_FLASK_SECRET 2020-11-09 12:01:14 +01:00
.drone.yml Add CI build 2020-10-26 17:39:44 +01:00
.gitignore Remove and ignore generated css 2020-11-09 04:53:30 +01:00
.snipenv Make docker default configuration production ready 2020-11-08 20:16:36 +01:00
.snipenv.local Use https as default scheme, run behind gunicorn in container 2020-11-09 05:37:17 +01:00
Dockerfile Remove flask host from docker 2020-11-09 06:59:17 +01:00
LICENSE Add README, fix license, add querysheet 2020-11-06 02:03:07 +01:00
package-lock.json Success page, prettifying shortener 2020-11-06 00:46:58 +01:00
package.json Add README, fix license, add querysheet 2020-11-06 02:03:07 +01:00
Pipfile .snipenv configuration 2020-11-08 14:20:41 +01:00
Pipfile.lock .snipenv configuration 2020-11-08 14:20:41 +01:00
querysheet.http Add README, fix license, add querysheet 2020-11-06 02:03:07 +01:00
README.md Configurable keylen, rename SNIP_FLASK_SECRET 2020-11-09 12:01:14 +01:00
snip.svg First version 2020-10-26 17:17:00 +01:00
snip_screen.png Add README, fix license, add querysheet 2020-11-06 02:03:07 +01:00
TODO.org Add README, fix license, add querysheet 2020-11-06 02:03:07 +01:00
webpack.common.js Success page, prettifying shortener 2020-11-06 00:46:58 +01:00
webpack.dev.js First version 2020-10-26 17:17:00 +01:00
webpack.prod.js Working shortener with some style 2020-10-30 00:59:31 +01:00

Snip

Build Status

No-fuzz link shortener.

Snip Screenshot

Getting started

Snip is a self-hosted link shortener. It provides an API and a web interface. Dependencies are managed with pipenv and npm. Snip runs on flask the frontend is assembled with webpack. All this is rather simple in practice.

Run from docker

The simplest way to get started is to run snip from the regularily published docker containers.

docker run -p5000 -e"SNIP_SECRET=secretkey" arminfriedl/snip:latest

Then navigate your browser to http://localhost:5000. Alternatively, you can also query the REST API. For an example see the querysheet.http in this repository. If you want to run it manually you can also install snip and its dependencies yourself.

Per default the container is configured with the following settings

SNIP_DATABASE="sqlite"
SNIP_DATABASE_URI="sqlite:////data/snip.db"
SNIP_FLASK_HOST="0.0.0.0"
# SNIP_FLASK_PORT=5000 (default)

You can mount an external folder under /data to persist all operational data of snip across restarts of the container.

Install and Run manually

While docker is convenient you may want to build and run snip yourself. E.g. for development or because you need special settings.

Install Dependencies

To install the dependencies for snip, you need pipenv and npm installed on your system. Then run:

pipenv install --dev
npm install --dev

Configure

Snip provides a couple of configuration options. For details see config.py::SnipConfig. An example configuration for local development is provided in .snipenv.local. Adapt the configuration to your needs.

You can also specify another stage in .snipenv by setting the variable SNIP_STAGE=[stage]. The configuration will then be read from .snipenv.[stage].

Build the Snip Frontend

The snip backend itself needs no separate build step. However, the frontend needs to be assembled by webpack.

# Run a development build with continuous update
npm run watch

# Run a production build
npm run publish

Run Snip

From the repository root run:

export SNIP_STAGE=local # or any other stage
pipenv run python -m snip

Flask will tell you where you can reach snip, per default http://localhost:5000.

Contribute

If you want to contribute to snip feel free to send patches to dev[at]friedl[dot]net. Alternatviely, you can issue a pull request on GitHub which will be cherry picked into my tree. If you plan significant long-term contributions drop me a mail for access to the incubator repository.

Github Users

If you are visiting this repository on GitHub, you are on a mirror of https://git.friedl.net/incubator/snip. This mirror is regularily updated with my other GitHub mirrors.

Like with my other incubator projects, once I consider snip reasonable stable the main tree will move to GitHub.