This repository has been archived by the owner on Jan 14, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better buffering, basic templating for documentation, refactoring, bo…
…otstrap executable
- Loading branch information
Showing
7 changed files
with
113 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{% extends "template.html" %} | ||
|
||
{% block title %}Index{% endblock %} | ||
{% block head %} | ||
{{ super() }} | ||
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css" rel="stylesheet"> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="span8 hero-unit"> | ||
<h1>Livestatus service</h1> | ||
|
||
<p> | ||
The livestatus-service exposes the functionality of a livestatus socket to the outside world over HTTP. | ||
</p> | ||
<ul> | ||
<li> | ||
<h2>Performing queries</h2> | ||
<p> | ||
<code>GET /query?q=<em>QUERY</em></code> | ||
</p> | ||
<p> | ||
Will perform a query using <em>QUERY</em>. An easy example would be | ||
<code>/query?q=GET%20hosts</code> | ||
</p> | ||
<p> | ||
If you need newlines, e.G. to add a filter, use <code>\n</code>. | ||
</p> | ||
</li> | ||
<li> | ||
<h2>Performing commands</h2> | ||
<p> | ||
<code>GET /cmd?q=<em>COMMAND</em></code> | ||
</p> | ||
<p> | ||
Will perform a command using <em>COMMAND</em>. The <code>COMMAND [%s]</code> directive will be inserted for you. | ||
An easy example would be <code>/cmd?q=DISABLE_HOST_SVC_CHECKS;devytc</code> | ||
</p> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{% endblock %} | ||
|
||
{% block footer %} | ||
<hr> | ||
<div class="container"> | ||
<div class="offset1 span5"> | ||
{{ super() }} | ||
</div> | ||
</div> | ||
|
||
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script> | ||
{% endblock %} | ||
|
||
|
19 changes: 19 additions & 0 deletions
19
src/main/python/livestatus_service/templates/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
{% block head %} | ||
<title>{% block title %}{% endblock %} - pypiproxy</title> | ||
{% endblock %} | ||
</head> | ||
<body> | ||
|
||
{% block content %}{% endblock %} | ||
|
||
<footer> | ||
{% block footer %} | ||
Livestatus service, version {{ version }} <br> | ||
© Copyright 2013 Marcel Wolf, Maximilien Riehl | ||
{% endblock %} | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
import logging | ||
|
||
from flask import Flask, request | ||
from flask import Flask, request, render_template | ||
from livestatus import perform_query, perform_command | ||
from livestatus_service import __version__ as livestatus_version | ||
|
||
LOGGER = logging.getLogger("livestatus.webapp") | ||
|
||
application = Flask(__name__) | ||
|
||
def render_application_template(template_name, **template_parameters): | ||
template_parameters["version"] = livestatus_version | ||
return render_template(template_name, **template_parameters) | ||
|
||
@application.route("/") | ||
def handle_index(): | ||
return ('todo', 200) | ||
return render_application_template("index.html", **locals()) | ||
|
||
|
||
@application.route('/query', methods=['GET']) | ||
def handle_query(): | ||
query_command = request.args.get('q') | ||
query_command = query_command.replace('\\n', '\n') | ||
query_result = perform_query(query_command) | ||
LOGGER.debug('Query {0} had result {1}'.format(query_command, query_result)) | ||
return ("{0}\n".format(query_result), 200) | ||
|
||
@application.route('/cmd', methods=['GET']) | ||
def handle_command(): | ||
command = request.args.get('q') | ||
command = command.replace('\\n', '\n') | ||
command_result = perform_command(command) | ||
LOGGER.debug('Command {0} had result {1}'.format(command, command_result)) | ||
return ("{0}\n".format(command_result), 200) |