Module azcam.tools.fastapi.fastapi_server

Configure and start fastapi application using uvicorn. Import this after all configuration has been completed. All API commands suported here must start with ""http://locahost:2402/api/".

URL example: "http://localhost:2402/api/instrument/set_filter?filter=1&filter_id=2"

Default response is JSON: response = { "message": "Finished", "command": urlparse(url).path, "data": reply, } If webserver.return_json is False, then just "data" is returned.

Classes

class WebServer

Azcam web server.

Methods

def add_router(self, router)

Add router.

def initialize(self)

Initialize application.

def parse(self, url, qpars=None)

Parse URL. Return the caller object, method, and keyword arguments. Object may be compound, like "exposure.image.focalplane".

URL example: http://locahost:2402/api/instrument/set_filter?filter=1&filter_id=2

def start(self)

Start web server.

def stop(self)

Stops command server running in thread.

def test_router(self)
def web_command(self, url, qpars=None)

Parse and execute a command string received as a URL. Returns the reply as a JSON packet.