neurolang.utils.server.app module¶
- class neurolang.utils.server.app.Application(nqm: NeurolangQueryManager)¶
Bases:
Application
tornado Application. Defines the routes which the application listens on. Holds the NeurolangQueryManager which manages queries / results.
- Parameters:
- nqmNeurolangQueryManager
the query manager
Methods
__call__
(request)Call self as a function.
add_handlers
(host_pattern, host_handlers)Appends the given handlers to our handler list.
find_handler
(request, **kwargs)Must be implemented to return an appropriate instance of ~.httputil.HTTPMessageDelegate that can serve the request.
get_handler_delegate
(request, target_class)Returns ~.httputil.HTTPMessageDelegate that can serve a request for application and RequestHandler subclass.
listen
(port[, address, family, backlog, ...])Starts an HTTP server for this application on the given port.
log_request
(handler)Writes a completed HTTP request to the logs.
on_close
(server_conn)This method is called when a connection has been closed.
reverse_url
(name, *args)Returns a URL path for handler named
name
start_request
(server_conn, request_conn)This method is called by the server when a new request has started.
add_transform
- class neurolang.utils.server.app.CancelHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
RequestHandler
Cancel an already running computation.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
head
initialize
options
patch
post
put
- class neurolang.utils.server.app.DownloadsHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
RequestHandler
Handle requests for file downloads.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get
(key)Serve the file for the given key.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
save_image_to_gzip
(df, col, idx)Save an image as nii.gz to a bytes array.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
head
initialize
options
patch
post
put
- async get(key: str)¶
Serve the file for the given key. Required query parameters are: - symbol: the symbol to download Optional query parameters: - col - idx the col and row index when a specific image file should be downloaded instead of the whole dataframe.
- Parameters:
- keystr
the unique id key, either for a query or for an engine type
- Raises:
- tornado.web.HTTPError
404 if key is invalid, or results are not available
- save_image_to_gzip(df: DataFrame, col: str, idx: str) BytesIO ¶
Save an image as nii.gz to a bytes array. The image should be an ExplicitVBR or ExplicitVBROverlay object located in the given dataframe at idx, col position.
- Parameters:
- dfpd.DataFrame
the dataframe containing the images
- colstr
the col index for the image in the df
- idxstr
the row index for the image in the df
- Returns:
- BytesIO
the bytes buffer with the compressed image data
- Raises:
- tornado.web.HTTPError
404 if object at given col, row indices is not the right type.
- set_default_headers()¶
Override this to set HTTP headers at the beginning of the request.
For example, this is the place to set a custom
Server
header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.
- class neurolang.utils.server.app.EmptyHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
RequestHandler
Helper endpoint returning an empty result.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
head
initialize
options
patch
post
put
- get()¶
- class neurolang.utils.server.app.EnginesHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
JSONRequestHandler
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
head
initialize
options
patch
post
put
write_json_reponse
- get()¶
- class neurolang.utils.server.app.JSONRequestHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
RequestHandler
Base Handler for writing JSON responses.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
head
initialize
options
patch
post
put
write_json_reponse
- set_default_headers()¶
Override this to set HTTP headers at the beginning of the request.
For example, this is the place to set a custom
Server
header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.
- class neurolang.utils.server.app.MainHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
RequestHandler
Serve the index page.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
head
initialize
options
patch
post
put
- get()¶
- class neurolang.utils.server.app.MpltFigureHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
RequestHandler
Handle requests for matplotlib figures. Streams them as svg.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get
(uuid)Serve the matplotlib figure requested.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
head
initialize
options
patch
post
put
- async get(uuid: str)¶
Serve the matplotlib figure requested. Required query parameters are: - symbol: the symbol containing the figures - col & row: the col and row index of the figure in the symbol’s dataframe.
- Parameters:
- uuidstr
the uuid of the query
- Raises:
- tornado.web.HTTPError
404 if uuid is invalid, or results are not available
- set_default_headers()¶
Override this to set HTTP headers at the beginning of the request.
For example, this is the place to set a custom
Server
header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.
- class neurolang.utils.server.app.NiftiiImageHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
JSONRequestHandler
Return the atlas image to be used by the Papaya viewer. Currently returns the MNI_MASK used by the engine configuration.
Image is returned as base64 encoded.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
head
initialize
options
patch
post
put
write_json_reponse
- get()¶
- class neurolang.utils.server.app.QueryHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
JSONRequestHandler
Main endpoint to submit a query using a POST request.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
head
initialize
options
patch
post
put
write_json_reponse
- async post()¶
- class neurolang.utils.server.app.QuerySocketHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
WebSocketHandler
Main handler to submit a query using a websocket.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
max_message_size
Maximum allowed message size.
- path_args
- path_kwargs
ping_interval
The interval for websocket keep-alive pings.
ping_timeout
If no ping is received in this many seconds, close the websocket connection (VPNs, etc.
selected_subprotocol
The subprotocol returned by select_subprotocol.
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_origin
(origin)Allow cross-origin websockets.
check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
close
([code, reason])Closes this Web Socket.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_compression_options
()Override to return compression options for the connection.
get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_close
()Invoked when the WebSocket is closed.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
on_message
(message)Upon receiving a message, extract the query from it and generate a uuid.
on_ping
(data)Invoked when the a ping frame is received.
on_pong
(data)Invoked when the response to a ping frame is received.
open
(*args, **kwargs)Invoked when a new WebSocket is opened.
ping
([data])Send ping frame to the remote end.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
select_subprotocol
(subprotocols)Override to implement subprotocol negotiation.
send_error
([status_code])Sends the given HTTP error code to the browser.
send_query_update
(future[, status])Upon completion of a query, send a message with the results
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_nodelay
(value)Set the no-delay flag for this stream.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
write_message
(message[, binary])Sends the given message to the client of this Web Socket.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
get_websocket_protocol
head
initialize
on_ws_connection_close
options
patch
post
put
- check_origin(origin)¶
Allow cross-origin websockets.
- async on_message(message)¶
Upon receiving a message, extract the query from it and generate a uuid. Submit the query to the NeurolangQueryManager and set send_query_update as the callback for when the query execution completes.
- Parameters:
- messagestr
a serialized JSON representation of an object containing a query.
- class neurolang.utils.server.app.StaticFileOrDefaultHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
StaticFileHandler
When serving static files, if file does not exist on path, return index.html instead.
This is only useful for dev mode, as static file handling is done by nginx in production.
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Sets the
Etag
header based on static url version.create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get_absolute_path
(root, path)Returns the absolute location of
path
relative toroot
.get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cache_time
(path, modified, mime_type)Override to customize cache control behavior.
get_content
(abspath[, start, end])Retrieve the content of the requested resource which is located at the given absolute path.
get_content_size
()Retrieve the total size of the resource at the given path.
get_content_type
()Returns the
Content-Type
header to be used for this request.get_content_version
(abspath)Returns a version string for the resource at the given path.
get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_modified_time
()Returns the time that
self.absolute_path
was last modified.get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
get_version
(settings, path)Generate the version string to be used in static URLs.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
make_static_url
(settings, path[, ...])Constructs a versioned url for the given path.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
parse_url_path
(url_path)Converts a static URL path into a filesystem path.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_extra_headers
(path)For subclass to add extra headers to the response
set_header
(name, value)Sets the given response header name and value.
set_headers
()Sets the content and caching headers on the response.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
should_return_304
()Returns True if the headers indicate that we should return 304.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
validate_absolute_path
(root, absolute_path)Validate and return the absolute path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
get
head
initialize
options
patch
post
put
reset
- validate_absolute_path(root: str, absolute_path: str) str | None ¶
Validate and return the absolute path.
root
is the configured path for the StaticFileHandler, andpath
is the result of get_absolute_pathThis is an instance method called during request processing, so it may raise HTTPError or use methods like RequestHandler.redirect (return None after redirecting to halt further processing). This is where 404 errors for missing files are generated.
This method may modify the path before returning it, but note that any such modifications will not be understood by make_static_url.
In instance methods, this method’s result is available as
self.absolute_path
.New in version 3.1.
- class neurolang.utils.server.app.StatusHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
JSONRequestHandler
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get
(uuid)Return the status (or the result) of an already running calculation. Optional query parameters are : * symbol : return only the values for this symbol * start : index of the first row to return * length : number of rows to return * sort : the index of the column to sort by * asc : sort by ascending (true) or descending (false).
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
head
initialize
options
patch
post
put
write_json_reponse
- async get(uuid: str)¶
Return the status (or the result) of an already running calculation. Optional query parameters are :
symbol : return only the values for this symbol
start : index of the first row to return
length : number of rows to return
sort : the index of the column to sort by
asc : sort by ascending (true) or descending (false)
- Parameters:
- uuidstr
The query id
- Returns:
- QueryResults
The query results.
- Raises:
- tornado.web.HTTPError
raises 404 if query id does not exist.
- class neurolang.utils.server.app.SymbolsHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)¶
Bases:
JSONRequestHandler
- Attributes:
cookies
An alias for self.request.cookies <.httputil.HTTPServerRequest.cookies>.
current_user
The authenticated user for this request.
locale
The locale for the current session.
- path_args
- path_kwargs
settings
An alias for self.application.settings <Application.settings>.
xsrf_token
The XSRF-prevention token for the current user/session.
Methods
add_header
(name, value)Adds the given response header and value.
check_etag_header
()Checks the
Etag
header against requests'sIf-None-Match
.check_xsrf_cookie
()Verifies that the
_xsrf
cookie matches the_xsrf
argument.clear
()Resets all headers and content for this response.
clear_all_cookies
(**kwargs)Attempt to delete all the cookies the user sent with this request.
clear_cookie
(name, **kwargs)Deletes the cookie with the given name.
clear_header
(name)Clears an outgoing header, undoing a previous set_header call.
compute_etag
()Computes the etag header to be used for this request.
create_signed_value
(name, value[, version])Signs and timestamps a string so it cannot be forged.
create_template_loader
(template_path)Returns a new template loader for the given path.
data_received
(chunk)Implement this method to handle streamed request data.
decode_argument
(value[, name])Decodes an argument from the request.
detach
()Take control of the underlying stream.
finish
([chunk])Finishes this response, ending the HTTP request.
flush
([include_footers])Flushes the current output buffer to the network.
get
(engine)Return the symbols available on an engine.
get_argument
(name[, default, strip])Returns the value of the argument with the given name.
get_arguments
(name[, strip])Returns a list of the arguments with the given name.
get_body_argument
(name[, default, strip])Returns the value of the argument with the given name from the request body.
get_body_arguments
(name[, strip])Returns a list of the body arguments with the given name.
get_browser_locale
([default])Determines the user's locale from
Accept-Language
header.get_cookie
(name[, default])Returns the value of the request cookie with the given name.
get_current_user
()Override to determine the current user from, e.g., a cookie.
get_login_url
()Override to customize the login URL based on the request.
get_query_argument
(name[, default, strip])Returns the value of the argument with the given name from the request query string.
get_query_arguments
(name[, strip])Returns a list of the query arguments with the given name.
get_secure_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_secure_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_signed_cookie
(name[, value, ...])Returns the given signed cookie if it validates, or None.
get_signed_cookie_key_version
(name[, value])Returns the signing key version of the secure cookie.
get_status
()Returns the status code for our response.
get_template_namespace
()Returns a dictionary to be used as the default template namespace.
get_template_path
()Override to customize template path for each handler.
get_user_locale
()Override to determine the locale from the authenticated user.
log_exception
(typ, value, tb)Override to customize logging of uncaught exceptions.
on_connection_close
()Called in async handlers if the client closed the connection.
on_finish
()Called after the end of a request.
prepare
()Called at the beginning of a request before get/post/etc.
redirect
(url[, permanent, status])Sends a redirect to the given (optionally relative) URL.
render
(template_name, **kwargs)Renders the template with the given arguments as the response.
render_embed_css
(css_embed)Default method used to render the final embedded css for the rendered webpage.
render_embed_js
(js_embed)Default method used to render the final embedded js for the rendered webpage.
render_linked_css
(css_files)Default method used to render the final css links for the rendered webpage.
render_linked_js
(js_files)Default method used to render the final js links for the rendered webpage.
render_string
(template_name, **kwargs)Generate the given template with the given arguments.
require_setting
(name[, feature])Raises an exception if the given app setting is not defined.
reverse_url
(name, *args)Alias for Application.reverse_url.
send_error
([status_code])Sends the given HTTP error code to the browser.
set_cookie
(name, value[, domain, expires, ...])Sets an outgoing cookie name/value with the given options.
set_default_headers
()Override this to set HTTP headers at the beginning of the request.
set_etag_header
()Sets the response's Etag header using
self.compute_etag()
.set_header
(name, value)Sets the given response header name and value.
set_secure_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_signed_cookie
(name, value[, ...])Signs and timestamps a cookie so it cannot be forged.
set_status
(status_code[, reason])Sets the status code for our response.
static_url
(path[, include_host])Returns a static URL for the given relative static file path.
write
(chunk)Writes the given chunk to the output buffer.
write_error
(status_code, **kwargs)Override to implement custom error pages.
xsrf_form_html
()An HTML
<input/>
element to be included with all POST forms.delete
head
initialize
options
patch
post
put
write_json_reponse
- get(engine: str)¶
Return the symbols available on an engine. This method is syncronous and will block until an engine is available to get its symbols.
- Optional query parameters are :
symbol : return only the values for this symbol
start : index of the first row to return
length : number of rows to return
sort : the index of the column to sort by
asc : sort by ascending (true) or descending (false)
- Parameters:
- enginestr
The engine id
- Returns:
- QueryResults
A dict of query results
- Raises:
- tornado.web.HTTPError
raises 404 if engine id does not exist
- neurolang.utils.server.app.main()¶
- neurolang.utils.server.app.setup_logs()¶