summaryrefslogtreecommitdiff
path: root/web_server.py
blob: cec8c38b491b21ab8798d7bb32c8ffc4eb92a379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

import cherrypy

class WebNotifyServer(object):

    def __init__(self):
        self.counter = 0

    @cherrypy.expose
    def notifications(self, **kwargs):
        self.counter += 1
        print(str(kwargs))
        print(self.counter)
        return ("called")


    @cherrypy.expose
    def other(self, **kwargs):
        self.counter += 1
        print(str(kwargs))
        print(self.counter)
        return ("called")


def main():

    cherrypy.config.update({
            'server.socket_host': '10.0.0.4',
            'server.socket_port': 40003,
            })

    try:
        cherrypy.quickstart(WebNotifyServer())

    except Exception as e:
        sys.stderr.write("WebServer error: {0}".format(e))
        sys.exit(1)

    sys.exit(0)


if __name__ == "__main__":
    main()