Skip to content

Instantly share code, notes, and snippets.

@hikoz
Created May 7, 2010 08:07
Show Gist options
  • Save hikoz/393172 to your computer and use it in GitHub Desktop.
Save hikoz/393172 to your computer and use it in GitHub Desktop.
import os.path
import markdown
HTML = """
<html>
<head>
<style type="text/css">
<!--
body {
font-family: Halvetica, sans-serif;
padding-left: 2em;
}
pre { padding-left: 2em }
-->
</style>
</head>
<body>
%s
</body>
</html>
"""
def app(environ, start_response):
name = os.path.basename(environ['PATH_INFO'])
txt = open(name).read().decode('utf-8')
body = markdown.markdown(txt).encode('utf-8')
start_response("200 OK", [])
return [HTML % body]
if __name__ == '__main__':
from wsgiref.simple_server import make_server
httpd = make_server('', 8000, app)
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment