reStructuredText basic server in Python
what is it
A very simple server which transforms ReST (reStructuredText) files to HTML on the fly. Errors during transformation will be sent to the browser too, so it is IMHO a quite useful development tool for ReST files. A "site" being build this way may also be published as static HTML with a simple converter script.
Inital version inspired by the
Twisted reStructuredText Server
from the ActiveState Cookbook site but working on a basic Python installation using the included
SimpleHTTPServer
. You may want to look there for improvements like caching though.
known limitations
-
The generated XHTML files should ideally be sent with mime-type
application/xhtml+xml
but as Docutils currently adds<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
the Content-Type headertext/html
is currently sent by the server too.
license
This module has been placed in the public domain. (New license from v2.0)
download
- restserver-2.0.zip 070911
- ( restserver.py v1.3 060111 - replace .txt with .py extension (very simple script version))
Tested with Python 2.5.1 and Docutils 0.5 on Windows XP only. Needs Python 2.4, Docutils 0.5 and optionally lxml if you want to convert all files to a static HTML version.
usage
See the provided example and docutils.conf which should be pretty self explanatory.
change history
- v2.0 070911
-
- extended docutils configuration file
- added full project with example CSS, Javascript (jQuery) etc.
- added converter to static HTML
- added HEAD in addition to GET method (e.g. if you like to access a file from the server and first want to check if it is present at all)
- needs docutils 0.5 to be able to use a template
- new licence
- v1.3 060111
-
- added txt2html.xsl which converts *.txt links to *.html
-
renamed
RSTEXT
toRST_EXT
-
if no path (or "
/
") is given, "index." +RST_EXT
is tried to prevent a maybe older index.html to be shown by default behaviour ofSimpleHTTPServer
- v1.2 050604
-
- supports command line options same as those for rst2html.py with a patch from Felix Wiemann
-
added constand
RSTEXT
to configure extension for ReST files the server looks for - added license, for questions please contact me
- v1.1 050531
-
- requests for ".html" are now tested if a ".txt" file with same name exists. If yes it will redirect to the ".txt" (which will be converted to HTML again) - useful for testing and also packages like the docutils documentation package which uses html links but by default files are ".txt" only
- v1.0 050521
- first release