From 8cdf6b11b83c5cf4f8d6af9321b3f0a8f98595b2 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Fri, 30 Nov 2012 15:00:44 +0100 Subject: add a flask template app --- code/templates/flask/app.py | 48 ++++++++++++++++++++++++++++++++ code/templates/flask/static/favicon.ico | 0 code/templates/flask/static/robots.txt | 2 ++ code/templates/flask/templates/base.html | 13 +++++++++ code/templates/flask/templates/home.html | 4 +++ 5 files changed, 67 insertions(+) create mode 100755 code/templates/flask/app.py create mode 100644 code/templates/flask/static/favicon.ico create mode 100644 code/templates/flask/static/robots.txt create mode 100644 code/templates/flask/templates/base.html create mode 100644 code/templates/flask/templates/home.html (limited to 'code') diff --git a/code/templates/flask/app.py b/code/templates/flask/app.py new file mode 100755 index 0000000..69d3c54 --- /dev/null +++ b/code/templates/flask/app.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +import os +import argparse +from flask import Flask, render_template, send_from_directory, request, \ + url_for, abort, flash, session, g, redirect + +app = Flask(__name__) +app.config.from_object(__name__) + +@app.route('/', methods=['GET']) +def homepage(): + return render_template('home.html') + +@app.route('/favicon.ico', methods=['GET']) +def favicon(): + """ Simple static redirect """ + return send_from_directory(os.path.join(app.root_path, 'static'), + 'favicon.ico', + mimetype='image/vnd.microsoft.icon') + +@app.route('/robots.txt', methods=['GET']) +def robots(): + """ "Just in case?" """ + return send_from_directory(os.path.join(app.root_path, 'static'), + 'robots.txt', + mimetype='text/plain') + +############################################################################# +def main(): + """Primary entry-point for torouterui. + """ + parser = argparse.ArgumentParser() + parser.add_argument('--debug', + action='store_true', + help="enable debugging interface") + parser.add_argument('--host', + default="127.0.0.1", + help="listen on this host/IP") + parser.add_argument('--port', + type=int, + default=5050, + help="listen on this port") + args = parser.parse_args() + app.run(debug=args.debug, host=args.host, port=args.port) + +if __name__ == '__main__': + main() diff --git a/code/templates/flask/static/favicon.ico b/code/templates/flask/static/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/code/templates/flask/static/robots.txt b/code/templates/flask/static/robots.txt new file mode 100644 index 0000000..fc5f235 --- /dev/null +++ b/code/templates/flask/static/robots.txt @@ -0,0 +1,2 @@ + +blah! diff --git a/code/templates/flask/templates/base.html b/code/templates/flask/templates/base.html new file mode 100644 index 0000000..1a3935f --- /dev/null +++ b/code/templates/flask/templates/base.html @@ -0,0 +1,13 @@ + + + + flask app template + + + + +{% block body %}{% endblock %} + + diff --git a/code/templates/flask/templates/home.html b/code/templates/flask/templates/home.html new file mode 100644 index 0000000..9825deb --- /dev/null +++ b/code/templates/flask/templates/home.html @@ -0,0 +1,4 @@ +{% extends "base.html" %} +{% block body %} +

template flask app

+{% endblock %} -- cgit v1.2.3