Skip to content

Instantly share code, notes, and snippets.

@joshourisman
Created January 4, 2011 16:26
Show Gist options
  • Save joshourisman/764995 to your computer and use it in GitHub Desktop.
Save joshourisman/764995 to your computer and use it in GitHub Desktop.
from flask import Flask, render_template, request
from urllib import unquote
app = Flask(__name__)
@app.route("/<slug>/")
def ekit_index(slug):
template = "%s/index.html" % slug
return render_template(template)
@app.route("/<path:template>", methods=['GET',])
def ekit_inner(template):
if template.endswith('/'):
template = "%sindex.html" % template
elif '.' not in template:
template = "%s/index.html" % template
else:
try:
args = request.url.split('?')[1]
template = "%s?%s" % (template, unquote(args))
except IndexError:
pass
return render_template(template)
if __name__ == "__main__":
app.debug = True
app.run(host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment