How to use the aj.api.endpoint.endpoint function in aj

To help you get started, we’ve selected a few aj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ajenti / ajenti / plugins / filesystem / views.py View on Github external
    @endpoint(api=True)
    def handle_api_fs_finish_upload(self, http_context):
        name = http_context.json_body()['name']
        path = http_context.json_body()['path']
        id = http_context.json_body()['id']
        chunk_dir = '/tmp/upload-%s' % id

        target = os.path.join(path, name.replace('/', ''))
        with open(target, 'wb') as f:
            for i in range(len(os.listdir(chunk_dir))):
                f.write(open(os.path.join(chunk_dir, str(i + 1))).read())

        shutil.rmtree(chunk_dir)
        return target
github ajenti / ajenti / plugins / datetime / views.py View on Github external
    @endpoint(api=True)
    def handle_api_tz_set(self, http_context, tz=None):
        return self.manager.set_tz(tz)
github ajenti / ajenti / plugins / packages / views.py View on Github external
    @endpoint(api=True)
    def handle_api_get(self, http_context, manager_id=None, package_id=None):
        return self.__package_to_json(self.managers[manager_id].get_package(package_id))
github ajenti / ajenti / plugins / network / views.py View on Github external
    @endpoint(api=True)
    def handle_api_config_get(self, http_context):
        return self.manager.get_config()
github ajenti / ajenti / plugins / packages / views.py View on Github external
    @endpoint(api=True)
    def handle_api_apply(self, http_context, manager_id=None):
        mgr = self.managers[manager_id]
        selection = json.loads(http_context.body)
        cmd = mgr.get_apply_cmd(selection)
        return {
            'terminalCommand': cmd,
        }
github ajenti / ajenti / plugins / power / views.py View on Github external
    @endpoint(api=True)
    def handle_api_uptime(self, http_context):
        return time.time() - psutil.boot_time()
github ajenti / ajenti / plugins / core / views / tasks.py View on Github external
    @endpoint(api=True)
    def handle_api_tasks_request_update(self, http_context):
        self.service.send_update()
github ajenti / ajenti / plugins / network / views.py View on Github external
    @endpoint(api=True)
    def handle_api_state(self, http_context, iface=None):
        return self.manager.get_state(iface)
github ajenti / ajenti / plugins / network / views.py View on Github external
    @endpoint(api=True)
    def handle_api_config_set(self, http_context):
        return self.manager.set_config(json.loads(http_context.body))
github ajenti / ajenti / plugins / core / views / resource_server.py View on Github external
    @endpoint(page=True, auth=False)
    def handle_file(self, http_context, plugin=None, path=None):
        if '..' in path:
            return http_context.respond_not_found()
        return http_context.file(PluginManager.get(aj.context).get_content_path(plugin, path))