Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Uses config file to list legal templates

  • Loading branch information...
commit 326b01b5dc099b070a39b76cba225e02712a8ebb 1 parent dac35f4
@poundifdef poundifdef authored
Showing with 12 additions and 3 deletions.
  1. +4 −3 app.py
  2. +8 −0 hacking.txt
View
7 app.py
@@ -1,3 +1,4 @@
+from config import TEMPLATES
import os
from flask import Flask, request, make_response, render_template
from jinja2.exceptions import TemplateNotFound
@@ -8,10 +9,10 @@
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def index(path):
- try:
+ if path in TEMPLATES:
return render_template(path + '/index.html', path=path)
- except TemplateNotFound as ex:
- return render_template("index.html")
+
+ return render_template("index.html")
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
View
8 hacking.txt
@@ -0,0 +1,8 @@
+To add a new template (new_template_name):
+
+1. Add a folder with that template's name to the templates/ directory
+ (templates/new_template_name)
+
+2. If necessary, add static files to static/new_template_name/
+
+3. Add the name of that template to the TEMPLATES variable in config.py
Please sign in to comment.
Something went wrong with that request. Please try again.