/
app.py
44 lines (34 loc) · 1012 Bytes
/
app.py
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
import os, sys
from flask import Flask, render_template, request, redirect, url_for
from flask.ext.basicauth import BasicAuth
from werkzeug import secure_filename
from os import path
app = Flask(__name__)
UPLOAD_FOLDER = '/path/to/the/uploads'
ALLOWED_EXTENSIONS = set(['gpx'])
app.config['BASIC_AUTH_USERNAME'] = 'hawaii'
app.config['BASIC_AUTH_PASSWORD'] = 'trails'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
def track_list():
path = os.getcwd() + "/static/gpx/"
files = []
dirs = os.listdir( path )
for file in dirs:
files.append(file)
return files
track_list = track_list()
@app.route('/')
def index():
return render_template('layout.html', files=track_list)
basic_auth = BasicAuth(app)
@app.route('/admin')
@basic_auth.required
def admin():
path = os.getcwd() + "/static/gpx/"
files = []
dirs = os.listdir( path )
for file in dirs:
files.append(file)
return render_template('admin.html', files=track_list)
if __name__ == '__main__':
app.run(debug = True)