server
Handles http api routing and serving with usage similar to flask.
Attributes
mlogger = get_logger(__name__)
module-attribute
Classes
Request(path='/', method='GET', data=None, params=None)
Bases: object
Request wrapper object.
Source code in pyrevitlib/pyrevit/routes/server/base.py
Attributes
path = path
instance-attribute
method = method
instance-attribute
data = data
instance-attribute
headers
property
Request headers dict.
params
property
Request parameters.
callback_url
property
Request callback url, if provided in payload.
Functions
Response(status=200, data=None, headers=None)
Bases: object
Response wrapper object.
Source code in pyrevitlib/pyrevit/routes/server/base.py
Attributes
status = status
instance-attribute
data = data
instance-attribute
headers
property
Response headers dict.
Functions
Functions
init()
Initialize routes. Reset all registered routes and shutdown servers.
activate_server()
Activate routes server for this host instance.
Source code in pyrevitlib/pyrevit/routes/server/__init__.py
deactivate_server()
Deactivate the active routes server for this host instance.
Source code in pyrevitlib/pyrevit/routes/server/__init__.py
get_active_server()
make_response(data, status=OK, headers=None)
Create Reponse object with.
get_routes(api_name)
Get all registered routes for given API name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_name |
str
|
unique name of the api |
required |
add_route(api_name, pattern, method, handler_func)
Add new route for given API name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_name |
str
|
unique name of the api |
required |
pattern |
str
|
route pattern |
required |
method |
str
|
method name |
required |
handler_func |
function
|
route handler function |
required |
Source code in pyrevitlib/pyrevit/routes/server/__init__.py
remove_route(api_name, pattern, method)
Remove previously registered route for given API name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_name |
str
|
unique name of the api |
required |
pattern |
str
|
route pattern |
required |
method |
str
|
method name |
required |