summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-02 23:33:03 +0100
committerAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-02 23:33:03 +0100
commit2a6d3eb44476b6dcc299ceab7044c04c8e3528af (patch)
tree0ea763678e7adade0f3cfd3e6b3e5543bba7964c
parentBasic HTTP server that prints out POST request info (diff)
downloadlog-analysis-2a6d3eb44476b6dcc299ceab7044c04c8e3528af.tar.gz
log-analysis-2a6d3eb44476b6dcc299ceab7044c04c8e3528af.tar.bz2
log-analysis-2a6d3eb44476b6dcc299ceab7044c04c8e3528af.zip
Move the application to the Flask framework
-rw-r--r--CollectionDaemon.py25
-rw-r--r--CollectionHTTPServer.py33
-rw-r--r--flask_app.py14
3 files changed, 14 insertions, 58 deletions
diff --git a/CollectionDaemon.py b/CollectionDaemon.py
deleted file mode 100644
index a728e75..0000000
--- a/CollectionDaemon.py
+++ /dev/null
@@ -1,25 +0,0 @@
-"""
-Implements a daemon that hosts the HTTP server for log collection.
-
-TODO:
- daemonisation
- implement both IPv4 and IPv6 modes
- proper shutdown
-"""
-
-import CollectionHTTPServer
-
-class CollectionDaemon:
-
- def __init__(self, port=8000):
- server_class = CollectionHTTPServer.HTTPServer6
- handler_class = CollectionHTTPServer.HTTPRequestHandler
-
- self.server_address = ('::', port)
- self.httpd = server_class(self.server_address, handler_class)
-
- def start(self):
- self.httpd.serve_forever()
-
-if __name__ == '__main__':
- CollectionDaemon().start()
diff --git a/CollectionHTTPServer.py b/CollectionHTTPServer.py
deleted file mode 100644
index d2982fd..0000000
--- a/CollectionHTTPServer.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""
-Implements the HTTP handler for log collection
-
-TODO:
- decide on exact protocol
- HTTP/1.1
- retrieve client's hostname
- send to analyser
- store in filesystem (later in storage backend)
- log groups
-"""
-
-import BaseHTTPServer
-import socket
-
-class HTTPServer6(BaseHTTPServer.HTTPServer):
-
- address_family = socket.AF_INET6
-
-class HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
-
- #protocol_version = "HTTP/1.1"
-
- def do_POST(self):
- print(self.client_address)
- print(self.command, self.path, self.request_version)
- print(self.headers.headers)
-
- size = int(self.headers.getheader('Content-Length'))
-
- print(self.rfile.read(size))
- self.send_response(200)
- self.end_headers()
diff --git a/flask_app.py b/flask_app.py
new file mode 100644
index 0000000..1bfd837
--- /dev/null
+++ b/flask_app.py
@@ -0,0 +1,14 @@
+"""
+The web application built on Flask is contained within this file.
+When run as a script, the Flask development server is started.
+"""
+
+from flask import Flask
+app = Flask(__name__)
+
+@app.route('/')
+def index():
+ pass
+
+if __name__ == '__main__':
+ app.run(host='::1', debug=True)