Skip to content

Cahoots Server Setup

Ryan Vennell edited this page Apr 4, 2015 · 13 revisions

Installation

  • Run the command sudo pip install cahoots to install Cahoots and its standalone web server.
  • Part of the Cahoots setup script includes extracting and importing the location database. This may take a few moments and you will see the process detailed as Cahoots installs.

Running the Server

  • Run the command cahootserver --help to view the usage details:
$ cahootserver --help

Cahoots Server Help:

	-h, --help
		Show this help

	-p [port], --port [port]
		Set the port the server should listen on

	-d, --debug
		Run the server in debug mode (errors displayed, debug output)
  • Note: Some ports require a privileged user.

Example with default values:

$ cahootserver
 * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)

Example with port 80 and debug mode:

$ sudo cahootserver --port 80 --debug
 * 00:38:18 04/04/15 CDT * Bootstrapping AddressParser
 * 00:38:18 04/04/15 CDT * Bootstrapping CoordinateParser
 * 00:38:18 04/04/15 CDT * Bootstrapping DateParser
 * 00:38:18 04/04/15 CDT * Bootstrapping EmailParser
 * 00:38:18 04/04/15 CDT * Bootstrapping LandmarkParser
 * 00:38:18 04/04/15 CDT * Bootstrapping MeasurementParser
 * 00:38:18 04/04/15 CDT * Bootstrapping PostalCodeParser
 * 00:38:18 04/04/15 CDT * Bootstrapping ProgrammingParser
 * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
 * Restarting with stat
 * 00:38:18 04/04/15 CDT * Bootstrapping AddressParser
 * 00:38:18 04/04/15 CDT * Bootstrapping CoordinateParser
 * 00:38:18 04/04/15 CDT * Bootstrapping DateParser
 * 00:38:18 04/04/15 CDT * Bootstrapping EmailParser
 * 00:38:18 04/04/15 CDT * Bootstrapping LandmarkParser
 * 00:38:18 04/04/15 CDT * Bootstrapping MeasurementParser
 * 00:38:18 04/04/15 CDT * Bootstrapping PostalCodeParser
 * 00:38:18 04/04/15 CDT * Bootstrapping ProgrammingParser
  • Once the server is running, incoming requests will generate console output similar to this:
127.0.0.1 - - [23/Mar/2015 18:51:07] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [23/Mar/2015 18:51:10] "POST / HTTP/1.1" 200 -
127.0.0.1 - - [23/Mar/2015 18:51:24] "POST /api/ HTTP/1.1" 200 -
  • As a server admin you may wish to set up your own configuration for startup execution and logging output. This web server is intentionally simple, and does not contain built-in options for automatic startup and logging. Eventually those options may be integrated.

Example of a simple, no-fuss setup:

$ sudo nohup cahootserver --port 80 >> /var/log/cahoots.log 2>&1 &

Using the API or Web Interface

  • Send a POST to http://your.cahoots.tld:[PORT]/api/ with the form-field snippet set to the value that you would like to analyze.
$ curl --data "snippet=5 x 5" http://your.cahoots.tld:[PORT]/api/
{
    "date": "2015-03-24T01:06:32.597534",
    "query": "5 x 5",
    "top": {
        "subtype": "Simple",
        "confidence": 100,
        "type": "Equation",
        "value": 25.0,
        "data": {}
    },
    "results": {
        "count": 1,
        "matches": [
            {
                "subtype": "Simple",
                "confidence": 100,
                "type": "Equation",
                "value": 25.0,
                "data": {}
            }
        ],
        "types": [
            "Equation"
        ]
    },
    "execution_seconds": 0.005945920944213867
}
  • Browse to http://your.cahoots.tld:[PORT]/ to view the cahoots web interface

Screenshot of the web interface: Cahoots Web Interface