Skip to content

Instantly share code, notes, and snippets.

@alyx
Created February 16, 2013 06:38
Show Gist options
  • Save alyx/4965837 to your computer and use it in GitHub Desktop.
Save alyx/4965837 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2.7
import web, os
from markdown import markdown
#####
# CONFIG:
#####
TITLE = "Stupid CMS Website"
BASE = "./docs"
CSS = "./docs/style.css"
# End config.
urls = ("/(.*)", "docs")
app = web.application(urls, globals())
def template(Path):
OutString = """
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<style type="text/css">
""" + open(CSS).read() + """
</style>
""" + "<title>" + Path + "</title>" + """
</head>
<body>
""" + markdown(open(BASE + "/" + Path + ".md").read()) + """
</body>
</html>"""
return OutString
class docs:
def GET(self, path):
newpath = os.path.normpath(path)
print(BASE + "/" + newpath + ".md")
if (os.path.isfile(BASE + "/" + newpath + ".md")):
print(template(newpath))
return template(newpath)
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment