Gopher library for Python 3

1.0 | Download Source | Examples | API | Repository | BSD 2-Clause License

Pituophis is a Gopher library/module for Python 3 that has functions for client and server.


How to Install

At a prompt, run pip3 install pituophis or pip install pituophis depending on your setup. You'll be able to import the package with `import pituophis`.

Server Quick Start

If you want to host a Pituophis-based Gopher server, put this code in a file:

import pituophis
pituophis.serve("", 7070, pub_dir='pub/', tls=False)  # typical Gopher port is 70 is the hostname as advertised to the client, and 7070 is the port. pub/ is the publish directory relative to the script.

Here's a basic alt handler, if you're familiar with Python scripting and would like to add more interactivity to your server:

def alt(request):
    if request.path == '/test':
        return [pituophis.Selector(text='test!')]

You can return a list of Selector objects, bytes, or text. To use your alt handler, add the argument alt_handler=alt to your serve() like this:

pituophis.serve("", 7070, pub_dir='pub/', alt_handler=alt, tls=False)

See more examples here and check out the full API here.

Gophermap Editor

Writing a Gophermap, a simplified form of a Gopher menu is pretty easy: just stick a file called gophermap in a folder within your publish directory and use the straight-forward menu syntax. This little webapp can help you get to grips with it (note that this uses jQuery). Copy the Gophermap code into your file.

Made with Pituophis

These are my personal projects that use Pituophis:

If you use Pituophis in your project, contact me and I'd be happy to put it down here.