Created
January 4, 2011 16:26
-
-
Save joshourisman/764995 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
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