Searching in Web Browser

class concordancer.server.ConcordancerBackend(Concordancer)[source]

Falcon API to serve the concordancer object for the query interface

Notes

Two API endpoints, /query and /export, are exposed. The endpoint /export accepts a GET request and responds by sending the most recent queried results back to the front-end in JSON format. The data sent back are identical to the data returned by cql_search() (converted to JSON). For the endpoint /query, see the doc in on_get()

Methods

on_get(req, resp)

Handling GET requests sent to /query

on_get_export(req, resp)

Handling GET requests sent to /export

on_get(req, resp)[source]

Handling GET requests sent to /query

Parameters
reqfalcon.request

Refer to falcon’s documentation

respfalcon.response

Refer to falcon’s documentation

Notes

Three parameters, query, left, and right are required in the query string of the URL sent to this endpoint. query holds the CQL query entered by the user. left and right set the left and right context sizes of the returned concordance lines.

Due to the conflicts between CQL metacharacters and URL specification, some characters are replaced with safe ones in the front-end and converted back to the original ones in the back-end. For the full set of characters converted, refer to URL_ESCAPES.

on_get_export(req, resp)[source]

Handling GET requests sent to /export

Parameters
reqfalcon.request

Refer to falcon’s documentation

respfalcon.response

Refer to falcon’s documentation

Notes

Sends the most recent queried results back to the front-end in JSON

concordancer.server.download_query_interface(url=None, force=True)[source]

Download and extract query interface from web

Parameters
urlstr, optional

URL of the dist.zip file containing the query interface. By default None, which uses the default URL specified by the library

forcebool, optional

Force download, by default True

concordancer.server.query_interface_path()[source]

Get the local path to the query interface

Returns
str

Path to the query interface

concordancer.server.run(Concordancer, port=1420, url=None, open_browser=True)[source]

Serve the concordancer object to allow searching with the web browser

Parameters
ConcordancerConcordancer

A concordancer object

portint, optional

The port the server listens on, by default 1420

urlstr, optional

Custom path to the query interface, by default None, which uses the path to local query interface bundled with the library

open_browserbool, optional

Automatically visit the url with the browser, by default True