simplerdfserver

SimpleRDFServer

Serves RDF (RSS 1.0) indexes of directories over HTTP

An underwhelming overridden version of the standard SimpleHTTPServer.py file from the standard Python modules (version 2.4.2), to produce RDF representations of directory listings. Subdirectories work as expected. Security (of any kind) is not implemented here. Run the test() command found in this file, and you'll start serving RDF of the current working directory over HTTP on port 8000. See the Python documentation for SimpleHTTPServer for the general idea. Work is ongoing!

-> Download SimpleRDFServer at The Python Cheeseshop

(requires easy_install from setuptools)

to install:

easy_install SimpleRDFServer

to upgrade:

easy_install -U SimpleRDFServer

To use:

python -c "from SimpleRDFServer import test; test()" (portnum)

or simply, SimpleRDFServer.py

(copied to your binary search path on install, so its a command!)

or also, python SimpleRDFServer.py 31337

(the port number is the only optional argument)

... and then visit http://localhost:(portnum)/ ... defaults to port 8000.

Some uses:

1. A great, quick way to generate triples based on files on your machine

#--------Begin example code

from rdflib import ConjunctiveGraph, Namespace

a=ConjunctiveGraph()

this=Namespace('http://localhost:8000/')

rdf=Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')

rss=Namespace('http://purl.org/rss/1.0/')

a.parse(this)

list(a.predicate_objects(this))

list(a.subjects(rdf.type,rss.item))

#--- end

2. Monitor a directory for changes as a live bookmark in FireFox (or another local feedreader).

3. Any other reason you may want a feed of a directory.

One could also generate static copies of the rdf file using wget ... really I haven't explored all the possibilities yet ;)

Enjoy! Oh, and there is no security on this script, so ya know, be firewalled whilst using.

History:

v0.2 - Links are now url encoded, paths (descriptions) are now escaped with HTML Entities

v0.1 - Initial Release

<< home