Skip to content

Commit

Permalink
updates to work with api hosting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcrendon committed Jun 12, 2023
1 parent 5f240b3 commit e7bb0a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: gunicorn apod.service:app --log-file=-
web: waitress-serve --port=8000 application:app
20 changes: 10 additions & 10 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#### added by justin for EB
#from wsgiref.simple_server import make_server

application = Flask(__name__)
CORS(application, resources={r"/*": {"expose_headers": ["X-RateLimit-Limit","X-RateLimit-Remaining"]} })
app = Flask(__name__)
CORS(app, resources={r"/*": {"expose_headers": ["X-RateLimit-Limit","X-RateLimit-Remaining"]} })

LOG = logging.getLogger(__name__)
# logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -253,24 +253,24 @@ def _get_json_for_date_range(start_date, end_date, use_concept_tags, thumbs):
# Endpoints
#

@application.route('/')
@app.route('/')
def home():
return render_template('home.html', version=SERVICE_VERSION,
service_url=request.host,
methodname=APOD_METHOD_NAME,
usage=_usage(joinstr='", "', prestr='"') + '"')

@application.route('/static/<asset_path>')
@app.route('/static/<asset_path>')
def serve_static(asset_path):
return current_app.send_static_file(asset_path)


@application.route('/' + SERVICE_VERSION + '/' + APOD_METHOD_NAME + '/', methods=['GET'])
@app.route('/' + SERVICE_VERSION + '/' + APOD_METHOD_NAME + '/', methods=['GET'])
def apod():
LOG.info('apod path called')
try:

# application/json GET method
# app/json GET method
args = request.args

if not _validate(args):
Expand Down Expand Up @@ -309,7 +309,7 @@ def apod():
return _abort(500, 'Internal Service Error', usage=False)


@application.errorhandler(404)
@app.errorhandler(404)
def page_not_found(e):
"""
Return a custom 404 error.
Expand All @@ -318,13 +318,13 @@ def page_not_found(e):
return _abort(404, 'Sorry, Nothing at this URL.', usage=True)


@application.errorhandler(500)
def application_error(e):
@app.errorhandler(500)
def app_error(e):
"""
Return a custom 500 error.
"""
return _abort(500, 'Sorry, unexpected error: {}'.format(e), usage=False)


if __name__ == '__main__':
application.run('0.0.0.0', port=5000)
app.run('0.0.0.0', port=8000)
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Note: The `lib` directory is added to `sys.path` by `appengine_config.py`.
flask>=1.0.2
flask-cors>=3.0.7
gunicorn==19.5.0
Jinja2>=2.8
Werkzeug>=0.10.4
beautifulsoup4==4.11.1
Expand All @@ -16,4 +15,5 @@ nose==1.3.7
setupext-janitor==1.0.0
bs4==0.0.1
mock>=3.0.0
Pillow>=9.3
Pillow>=9.3
waitress==2.1.2

0 comments on commit e7bb0a4

Please sign in to comment.