#!/usr/bin/python # -*- coding: utf-8 -*- """A super-minimal but hopefully reliable Wiki server in Python. """ import socket, thread, sys, cgi, pickle, os, errno, urlparse, email.parser, re def main(fname, port): docs = pickle.load(open(fname)) if os.path.exists(fname) else {} s = socket.socket() s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # avoid errno 98 s.bind(('', port)) s.listen(5) lock = thread.allocate_lock() while True: thread.start_new_thread(serve, (fname, docs, lock, s.accept())) def serve(fname, docs, lock, (c, _)): f = c.makefile() method, path = f.readline().split()[:2] # XXX this is failing! with lock: old = docs.get(path) edit_form = ("