fcs.server.web_interface

In this module web methods for managing Task Server are defined. These methods are implemented as classes that contain proper POST and GET methods. Requests are encapsulated in JSON messages.

class index

Returns diagnostic information about Task Server’s efficiency, assigned crawlers and links packages sent to them.

Returns:Diagnostic information.
Return type:JSON
class feedback

Sends user’s feedback with rating of crawled data. Required POST parameters are:

  • link - rated link
  • rating - rating of the given link
Returns:Feedback sending confirmation.
Return type:string
class put_data

Handles crawled data package received from crawler. Required POST parameters are:

  • id - crawled data package ID
  • data - crawled data
Returns:Confirmation.
Return type:string
class stats

Returns statistics summarise from given time period. Required POST parameters are:

  • seconds - number of seconds for which measurement was done (this method returns statistics since (now - seconds)).
Returns:Statistics (number of links crawled during the given period (now - seconds) and crawling speed assigned to this Task Server).
Return type:JSON
class crawlers

Assigns crawlers to the Task Server. Required POST parameters are:

  • crawlers - list of addresses of crawlers to assign to this Task Server
Returns:Confirmation.
Return type:string
class speed

Assigns new Task Server speed (expressed as URLs processed per minute). Required POST parameters are:

  • urls_per_min - new Task Server speed
Returns:Confirmation.
Return type:string
class update

Informs about changes of task’s settings (i.a. about its stopping, pausing, change of its priority, etc.).

Returns:Confirmation.
Return type:string
class stop

Stops Task Server.

Returns:Confirmation.
Return type:string
class get_data

Gets crawled data and saves them in a file.

Returns:File with crawling results.
Return type:stream
class alive

Informs if Task Server is alive.

Returns:Information if Task Server is alive.
Return type:string
class kill

Kills a Task Server.

Returns:Confirmation.
Return type:string
class WebServer(address='0.0.0.0', port=8800)

Wrapper for Task Server’s REST API.

Parameters:
  • port (int) – Server’s port.
  • address (string) – Server’s address.
urls

Mapping between URLs and web methods.

app

Server is run as a web application. This attribute is an object representing that web application.

run()

Runs this server.

get_host()

Returns server’s address with its port.

Returns:Server’s address with its port in the following format: address:port.
Return type:string
stop()

Stops this server.