Add feed display script and "Whoops!" homepage

This commit is contained in:
Hippo 2019-08-16 18:58:06 +05:30
parent b5edaa82d4
commit 4e3d5b64b0

28
app.py
View file

@ -1,17 +1,25 @@
from flask import Flask from flask import Flask, Response
from datetime import datetime
app = Flask(__name__) app = Flask(__name__)
@app.route('/feed.xml')
def feed():
lines = []
with open('feed.xml', 'r') as f:
for l in f.readlines():
lines.append(l)
return Response('\n'.join(lines),
mimetype='application/rss+xml')
@app.route('/') @app.route('/')
def homepage(): def homepage():
the_time = datetime.now().strftime("%A, %d %b %Y %l:%M %p") return '''
<h1>Whoops!</h1>
return """ <p>
<h1>Hello heroku</h1> Hey! We're currently having some problems with our website,
<p>It is currently {time}.</p> since our server is down. We'll be back soon though. Thanks
for your patience!
<img src="http://loremflickr.com/600/400"> </p>
""".format(time=the_time) '''
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True, use_reloader=True) app.run(debug=True, use_reloader=True)