Skip to content

Commit

Permalink
Move to common api, create public route, update nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
agahkarakuzu committed Dec 11, 2023
1 parent c5db1d4 commit b446469
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
11 changes: 10 additions & 1 deletion api/neurolibre_common_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,13 @@ def api_unlock_build(user, repo_url):
response = make_response(f"No build lock found for {repo_url}",404)

response.mimetype = "text/plain"
return response
return response

@common_api.route('/public/data', methods=['GET'])
@doc(description='List the name of folders under /DATA.', tags=['Data'])
def api_preview_list(user):
"""
This endpoint is to list the contents of the /DATA folder.
"""
files = os.listdir('/DATA')
return make_response(jsonify(files),200)
14 changes: 1 addition & 13 deletions api/neurolibre_preview_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,4 @@ def get_task_status_test(user,task_id):
}
return jsonify(response)

docs.register(get_task_status_test)

@app.route('/api/list', methods=['GET'])
@htpasswd.required
@doc(description='List the name of folders under /DATA.', tags=['Test'])
def api_preview_list(user):
"""
This endpoint is to list the contents of the /DATA folder.
"""
files = os.listdir('/DATA')
return jsonify(files)

docs.register(api_preview_list)
docs.register(get_task_status_test)
12 changes: 8 additions & 4 deletions nginx/neurolibre-preview.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ server{
client_max_body_size 4G;
keepalive_timeout 5;


auth_basic "Administrator’s Area";
auth_basic_user_file /home/ubuntu/.htpasswd;

location /api/ {
auth_basic "Administrator’s Area";
auth_basic_user_file /home/ubuntu/.htpasswd;
include /etc/nginx/neurolibre_params;
proxy_pass http://app_server;
}

location /public/ {
auth_basic off;
include /etc/nginx/neurolibre_params;
proxy_pass http://app_server;
}
Expand Down

0 comments on commit b446469

Please sign in to comment.