Created
February 16, 2013 06:38
-
-
Save alyx/4965837 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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