summaryrefslogtreecommitdiffstats
path: root/code/templates/flask/app.py
blob: 69d3c549ddb74a000dfaba4395d9cbfc5c1b9a95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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()