Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load-frontend-fits-file-uri #708

Merged
merged 8 commits into from
Sep 4, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions cdci_data_analysis/flask_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import string
import random
import hashlib

import requests
import validators
import re
import logging
Expand Down Expand Up @@ -535,6 +537,34 @@
return redirect(location, 302)


@app.route('/load-frontend-fits-file-url')
def load_frontend_fits_file_url():
par_dic = request.values.to_dict()
sanitized_request_values = sanitize_dict_before_log(par_dic)
logger.info('\033[32m===========================> load_frontend_file_uri\033[0m')

Check warning on line 544 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L542-L544

Added lines #L542 - L544 were not covered by tests

logger.info('\033[33m raw request values: %s \033[0m', dict(sanitized_request_values))

Check warning on line 546 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L546

Added line #L546 was not covered by tests

token = par_dic.pop('token', None)
app_config = app.config.get('conf')
secret_key = app_config.secret_key
output, output_code = tokenHelper.validate_token_from_request(token=token, secret_key=secret_key,

Check warning on line 551 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L548-L551

Added lines #L548 - L551 were not covered by tests
# TODO do we actually need a special role for this?
required_roles=None,
action="post on the product gallery")

if output_code is not None:
return make_response(output, output_code)

Check warning on line 557 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L556-L557

Added lines #L556 - L557 were not covered by tests

fits_file_url = request.values.get('fits_file_url', None)

Check warning on line 559 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L559

Added line #L559 was not covered by tests

if fits_file_url is not None:
response = requests.get(fits_file_url)
Fixed Show fixed Hide fixed
return Response(response.content, status=response.status_code, mimetype='application/octet-stream')

Check warning on line 563 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L561-L563

Added lines #L561 - L563 were not covered by tests
else:
raise MissingRequestParameter("url_request not provided")

Check warning on line 565 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L565

Added line #L565 was not covered by tests


@app.route('/call_back', methods=['POST', 'GET'])
def dataserver_call_back():
sanitized_request_values = sanitize_dict_before_log(request.values)
Expand Down
Loading