/paste-py

Paste service that uses Pygments

Primary LanguageCSSDo What The F*ck You Want To Public LicenseWTFPL

Paste-py

Modified version by myself to add password security to the app

Paste-py is a dead simple paste service written in Python. An instance of the original script is running at http://paste.awesom.eu.

To do :

  • Don’t protect the full app with a password, only users

Using it

Script

The most useful utility is the paste.sh script: save it somewhere in your path and use it as follows:

  • paste.sh foo will paste the content of the file foo and return the URL of the paste
  • paste.sh - will paste what it reads from stdin and the URL of the paste

You can also put the language to highlight with and the user as second and third argument (though the language will be detected from the extension).

You can look at the parameters at the beginning of the script to set a default user or automatically copy the paste URL.

Arguments

With paste-py, everything happens in the arguments you give in the URL. Every argument is prepended by a &. The following arguments can be used:

  • ln: add line numbers to the paste
  • hl=foo: syntax highlight the paste as language foo
  • raw: raw paste, to download it; you can also use the prefix /raw/ to have a shell-friendly URL (eg. http://paste.awesom.eu/raw/HiT)
  • script: used to paste from a script (will only return the URL, no html)

Users

Users are also supported: enter a username (eg. foobar) when pasting something, and you can access all your pastes by browsing http://paste.awesom.eu/user/foobar. Note that you cannot delete your pastes, so think twice before pasting something sensitive. In case you really need to delete a paste, contact me.

Passwords

This version of Paste-py is protected by password (ie. you won’t be able to acces the application without going through the login page, which ask you for a password). I create this when I was studying in the IUT of Nantes. With two friends we were using past-awesom.eu a lot to exchange source code, but bad intended peoples used to go check our pastes and re-use them. To avoid this, I’ve reworked a bit this script which is originaly from https://github.com/acieroid/paste-py to add a password protection. Check below to see how to setup the password.

Installing

The only dependencies are Tornado and Pygments. If you want to use the script to launch paste-py as a daemon, grizzled is also needed.

Password setting

There’s two thing to do in order to setup the password. First, input your password in the global var PASSWORD (located on the top of the paste.py file). Then, go to the end of the file, in the line cookie_secret“azertyuiopqsdfghjklmwxcvbn”= and replace the content with a anything you want. This is the string used to salt the cookie used to check if a user is authentified.

$ pip install tornado pygments grizzled

Launching

You can either launch it as a daemon or not: launch daemonize.py or paste.py. Look at the help (--help) if you want to change the listening address. For example:

$ LANG=en_US.UTF-8 python paste.py --addr=0.0.0.0 --port=8080

Design

The design is pretty basic, but some people made improvements to it. If you want a better design, look at http://paste.isomorphis.me/.

License

WTFPL, ie. do what the fuck you want with it.