Add feed display script and "Whoops!" homepage
This commit is contained in:
parent
b5edaa82d4
commit
4e3d5b64b0
1 changed files with 18 additions and 10 deletions
28
app.py
28
app.py
|
@ -1,17 +1,25 @@
|
|||
from flask import Flask
|
||||
from datetime import datetime
|
||||
from flask import Flask, Response
|
||||
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('/')
|
||||
def homepage():
|
||||
the_time = datetime.now().strftime("%A, %d %b %Y %l:%M %p")
|
||||
|
||||
return """
|
||||
<h1>Hello heroku</h1>
|
||||
<p>It is currently {time}.</p>
|
||||
|
||||
<img src="http://loremflickr.com/600/400">
|
||||
""".format(time=the_time)
|
||||
return '''
|
||||
<h1>Whoops!</h1>
|
||||
<p>
|
||||
Hey! We're currently having some problems with our website,
|
||||
since our server is down. We'll be back soon though. Thanks
|
||||
for your patience!
|
||||
</p>
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, use_reloader=True)
|
||||
|
|
Loading…
Reference in a new issue