bottle_gui package¶
- bottle_gui.bottle_gui.TEMPLATE_PATH = 'static/templates/'¶
Path to the template directory.
- bottle_gui.bottle_gui.read_template(template_name)[source]¶
Read content of the template file.
Parameters: template_name (str) – Name of the file. Returns: Content of template_name from TEMPLATE_PATH directory. Return type: str
- bottle_gui.bottle_gui.INDEX_TEMPLATE = '<HTML>\n<head>\n <title>API index</title>\n <link rel="stylesheet" type="text/css" href="bottle_gui_static/style.css">\n</head>\n\n<body>\n<h1>API list</h1>\n\n<p>\nNote, that you can also query this URL using\n<acronym title=\'curl -i -H "Accept: application/json" localhost:8888\'>\n <code>Accept: application/json</code>\n</acronym> header and you will get nested dictionaries.\n</p>\n\n$tables\n\n</body>\n</HTML>'¶
static/templates/index.html
- bottle_gui.bottle_gui.TABLE_TEMPLATE = '\n<table class="api_table">\n <tr>\n <th colspan="2" class="api_name">\n <h2><a href="$name">$name</a></h2>\n </th>\n </tr>\n <tr>\n <td colspan="2" class="api_description">$description</td>\n </tr>\n$rows\n</table>\n'¶
static/templates/table.html
- bottle_gui.bottle_gui.ROW_TEMPLATE = ' <tr style="border-top: 1px solid black;">\n <td class="request_type">$http_type</td>\n <td class="method_name">\n <b><a href="$name">$name</a></b> $args\n </td>\n </tr>\n$method_description'¶
static/templates/row.html
- bottle_gui.bottle_gui.DESCR_TEMPLATE = '\n <tr>\n <td class="blank_td">→</td>\n <td class="method_description">$method_description</pre></td>\n </tr>\n'¶
static/templates/descr.html
- class bottle_gui.bottle_gui.RouteInfo(method, path, args, docstring, mdocstring, module_name)[source]¶
Bases: object
Container for informations about route.
- method¶
fn reference
Reference to undecorated function.
- path¶
str
Path to the function in bottle.
- args¶
list
Args of the function.
- docstring¶
str
Docstring for the function.
- mdocstring¶
str
Docstring for the module where the function is.
- module_name¶
str
Name of the module where the function is.
Attributes method (fn reference): see Attributes section for details. path (str): see Attributes section for details. args (list): see Attributes section for details. docstring (str): see Attributes section for details. mdocstring (str): see Attributes section for details. module_name (str): see Attributes section for details.
- to_html()[source]¶
Convert informations about this route to HTML.
Note
DESCR_TEMPLATE and ROW_TEMPLATE is used.
Returns: HTML representation of the route. Return type: str
- class bottle_gui.bottle_gui.RouteGroup(routes=[])[source]¶
Bases: object
This object is used to group RouteInfo objects.
Parameters: routes (list, default []) – List with RouteInfo objects. - get_docstring()[source]¶
Return ‘module’ docstring.
Returns: Module docstring, if defined, or blank string. Return type: str
- to_html()[source]¶
Convert group and all contained paths to HTML.
Note
TABLE_TEMPLATE is used.
Returns: HTML. Return type: str
- bottle_gui.bottle_gui.list_routes()[source]¶
Get list of RouteInfo objects from bottle introspection.
Returns: RouteInfo objects. Return type: list
- bottle_gui.bottle_gui.group_routes(ungrouped_routes)[source]¶
Group list of RouteInfo objects in ungrouped_routes by their RouteInfo.path properties.
Parameters: ungrouped_routes (list) – List of RouteInfo objects. Returns: RouteGroup objects. Return type: list
- bottle_gui.bottle_gui.to_html(grouped_routes)[source]¶
Convert list of RouteGroup objects in group_routes to HTML.
Parameters: grouped_routes (list) – Llist of RouteGroup objects. Returns: HTML page with routes. Return type: str
- bottle_gui.bottle_gui.to_json(grouped_routes)[source]¶
Convert list of RouteGroup objects in grouped_routes to JSON.
Parameters: grouped_routes (list) – Llist of RouteGroup objects. Returns: JSON representation of grouped_routes. Return type: str