summaryrefslogtreecommitdiffstats
path: root/code/templates/flask/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'code/templates/flask/app.py')
-rwxr-xr-xcode/templates/flask/app.py48
1 files changed, 48 insertions, 0 deletions
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()