Skip to content

Commit

Permalink
Merge pull request #111 from nasa/master
Browse files Browse the repository at this point in the history
latest eb updates
  • Loading branch information
dcrendon authored Jun 12, 2023
2 parents 3d48942 + e7bb0a4 commit b4e32a8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ cd apod-api
```
3. Create a new virtual environment `env` in the directory
```bash
python -m virtualenv env
python -m venv venv
```
4. Activate the new environment
```bash
source env/bin/activate
.\venv\Scripts\Activate
```
5. Install dependencies in new environment
```bash
Expand Down
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)
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# 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.5.3
beautifulsoup4==4.11.1
requests>=2.20.0
coverage==4.1
nose==1.3.7
setupext-janitor==1.0.0
bs4==0.0.1
mock>=3.0.0
Pillow==8.3.2
Pillow>=9.3
waitress==2.1.2
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.6.1
python-3.11

0 comments on commit b4e32a8

Please sign in to comment.