Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Uses config file to list legal templates

  • Loading branch information...
commit 326b01b5dc099b070a39b76cba225e02712a8ebb 1 parent dac35f4
Jay Goel poundifdef authored

Showing 2 changed files with 12 additions and 3 deletions. Show diff stats Hide diff stats

  1. +4 3 app.py
  2. +8 0 hacking.txt
7 app.py
... ... @@ -1,3 +1,4 @@
  1 +from config import TEMPLATES
1 2 import os
2 3 from flask import Flask, request, make_response, render_template
3 4 from jinja2.exceptions import TemplateNotFound
@@ -8,10 +9,10 @@
8 9 @app.route('/', defaults={'path': ''})
9 10 @app.route('/<path:path>')
10 11 def index(path):
11   - try:
  12 + if path in TEMPLATES:
12 13 return render_template(path + '/index.html', path=path)
13   - except TemplateNotFound as ex:
14   - return render_template("index.html")
  14 +
  15 + return render_template("index.html")
15 16
16 17 if __name__ == "__main__":
17 18 port = int(os.environ.get("PORT", 5000))
8 hacking.txt
... ... @@ -0,0 +1,8 @@
  1 +To add a new template (new_template_name):
  2 +
  3 +1. Add a folder with that template's name to the templates/ directory
  4 + (templates/new_template_name)
  5 +
  6 +2. If necessary, add static files to static/new_template_name/
  7 +
  8 +3. Add the name of that template to the TEMPLATES variable in config.py

0 comments on commit 326b01b

Please sign in to comment.
Something went wrong with that request. Please try again.