Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tatwell committed Jul 26, 2015
2 parents 9f030fb + 4f34616 commit f80f2d1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
33 changes: 32 additions & 1 deletion app-engine/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# Imports
#
from os.path import dirname, join
import arrow
import dateutil

from flask import Flask, render_template
from flask import Flask, render_template, jsonify


#
Expand All @@ -27,6 +29,35 @@ def main_index():
"""Home page."""
return render_template('index.html')

# Arrow API
# Mainly to test fix for this issue:
#
@app.route('/arrow/version')
def arrow_version():
return jsonify({
'arrow': arrow.VERSION,
'dateutil': dateutil.__version__
})

@app.route('/arrow/now')
@app.route('/arrow/now/<timezone>')
def arrow_now(timezone=None):
now = arrow.utcnow()
json_data = {
'now': str(now),
'timezone': 'UTC'
}

if timezone:
timezone = timezone.replace('-', '/')
json_data['timezone'] = timezone
try:
json_data['now'] = str(now.to(timezone))
except arrow.parser.ParserError, e:
json_data['now'] = None
json_data['error'] = str(e)

return jsonify(json_data)

#
# Exception Handlers
Expand Down
6 changes: 6 additions & 0 deletions app-engine/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
#
# Note: The `lib` directory is added to `sys.path` by `appengine_config.py`.
Flask==0.10

# Arrow requires dateutil and dateutil > 1.5 requires subprocess module which App Engine
# does not allow. So we peg dateutil here to 1.5.
# See https://github.com/crsmithdev/arrow/issues/240
arrow
python-dateutil==1.5

0 comments on commit f80f2d1

Please sign in to comment.