changeset 19:be6a1aaec717

added the post listener, write logs if someone sends a post
author sean
date Tue, 11 Aug 2015 14:18:09 +0200
parents 3da0d624bec0
children 1a13a4ecf931
files dash.conf dash.py views/bottledash_view.tpl
diffstat 3 files changed, 30 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/dash.conf	Wed Aug 05 13:38:15 2015 +0200
+++ b/dash.conf	Tue Aug 11 14:18:09 2015 +0200
@@ -20,6 +20,8 @@
 
 [settings]
 show_top_bar=False
+rows=2
+check_interval=5
 
 # Tiles:
 # example:
@@ -71,7 +73,7 @@
 div_name=techintern
 script=display_issues_techintern
 
-[tile5]
-type=d3js
-div_name=webview_test
-script=webview_template
+#[tile5]
+#type=d3js
+#div_name=webview_test
+#script=webview_template
--- a/dash.py	Wed Aug 05 13:38:15 2015 +0200
+++ b/dash.py	Tue Aug 11 14:18:09 2015 +0200
@@ -6,7 +6,8 @@
 
 from bottle import get, post, request, view, response, route
 from bottle import template, run, static_file, error
-import os.path,sys,configparser,functools,bottle
+import os.path, sys, configparser, functools, bottle
+import logging
 
 CONFIG_FILE = "dash.conf"
 PATH = os.path.abspath(os.path.dirname(sys.argv[0]))
@@ -24,10 +25,18 @@
 settings = {}
 
 default_settings = configparser.ConfigParser()
-default_settings['settings'] = {'show_top_bar': False}
+default_settings['settings'] = {'show_top_bar': False, 'rows': 2}
+
+#logging:
+
+logger = logging.getLogger('myapp')
+hdlr = logging.FileHandler(PATH + '/bottledash.log')
+formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
+hdlr.setFormatter(formatter)
+logger.addHandler(hdlr)
+logger.setLevel(logging.INFO)
 
 ##read the config file. usually "dash.conf"
-
 def read_config():
 
     # print(PATH)
@@ -139,6 +148,17 @@
 def call_dashboard():
     return dict(tiles=tiles, settings=settings)
 
+@post('/updown')
+def updown():
+    service = request.forms.get('service')
+    status = request.forms.get('status')
+
+    logger.info('------- new alert --------')
+    logger.info('Service : ' + str(service))
+    logger.info('Status : ' + str(status))
+    logger.info('--------------------------')
+    return "thx! :: " + str(service) + " is " + str(status) + " !"
+
 @route('/config')
 def call_config():
     return 'Not implemented yet'
--- a/views/bottledash_view.tpl	Wed Aug 05 13:38:15 2015 +0200
+++ b/views/bottledash_view.tpl	Tue Aug 11 14:18:09 2015 +0200
@@ -3,8 +3,6 @@
 License: GNU GPL >= v2. See LICENSE for details. -->
 
 <%
-
-
     import math, os, sys, subprocess, html.parser
     from datetime import date
 
@@ -29,7 +27,7 @@
                     "Juni", "Juli", "August", "September", "Oktober",
                     "November", "Dezember")[today.month-1]
 
-    number_of_rows = 1
+    number_of_rows = 2
 
     #################
     # viewport size #
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)