-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.py
More file actions
51 lines (37 loc) · 1.41 KB
/
app.py
File metadata and controls
51 lines (37 loc) · 1.41 KB
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
49
50
51
from datetime import datetime, timedelta
from flask import Flask, render_template, make_response, redirect
from flask_assets import Environment, Bundle
from flask_compress import Compress
app = Flask(__name__, static_folder='static', static_url_path='')
assets = Environment(app)
scss = Bundle('scss/index.scss',
filters='scss', output='gen/all.css')
assets.register('scss', scss)
cmp = Compress(app)
STATIC_URL = '/static/'
@app.route('/')
def index():
return render_template("index.html")
@app.route('/organizers')
def organizers():
return render_template("organizers.html")
@app.route('/live')
def live():
return redirect('https://live.superhack.org')
@app.route('/document/prospectus.pdf')
def document():
return render_template("document.html", document_name="prospectus.pdf")
@app.route('/sitemap.xml', methods=['GET'])
def sitemap():
pages = []
ten_days_ago = datetime.now() - timedelta(days=3)
for rule in app.url_map.iter_rules():
if 'GET' in rule.methods and len(rule.arguments) == 0 and not rule.rule.startswith('/admin'):
pages.append(['https://superhack.org' + rule.rule, ten_days_ago])
sitemap_template = render_template('sitemap.xml', pages=pages)
response = make_response(sitemap_template)
response.headers["Content-Type"] = "application/xml"
return response
if __name__ == '__main__':
app.jinja_env.cache = {}
app.run(debug=True)