]> www.vanbest.org Git - motioneye-debian/commitdiff
added more urls and handlers
authorCalin Crisan <ccrisan@gmail.com>
Sat, 21 Sep 2013 11:56:29 +0000 (14:56 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 21 Sep 2013 11:56:29 +0000 (14:56 +0300)
doc/requirements.txt
doc/todo.txt [new file with mode: 0644]
src/handlers.py
src/server.py
temp/.gitkeep [new file with mode: 0644]

index 12bb981bf1f84fb93210a8901d1874272d77c7d0..c89b277c830bfcce6362d949e28a79b183efdb88 100644 (file)
@@ -4,6 +4,5 @@ jinja2
 
 ffmpeg
 motion
-nginx
 v4l-utils
 smbclient
diff --git a/doc/todo.txt b/doc/todo.txt
new file mode 100644 (file)
index 0000000..ee68a78
--- /dev/null
@@ -0,0 +1,7 @@
+-> browser compatibility test
+-> authentication
+-> proxy for slave motioneyes
+-> add a view log functionality
+-> click to zoom on cameras
+-> add a previewer for movies
+-> add a previewer for snapshots
index cd84cbfe1cec6afcbfc02157d3a5dfb38e066505..cd78db673bcc9b9894653f19d0fd879a4c4ce989 100644 (file)
@@ -1,5 +1,8 @@
 
-from tornado.web import RequestHandler
+import json
+import logging
+
+from tornado.web import RequestHandler, HTTPError
 
 import template
 
@@ -10,8 +13,90 @@ class BaseHandler(RequestHandler):
         
         content = template.render(template_name, **context)
         self.finish(content)
+    
+    def finish_json(self, data={}):
+        self.set_header('Content-Type', 'application/json')
+        self.finish(json.dumps(data))
 
 
 class MainHandler(BaseHandler):
     def get(self):
         self.render('main.html')
+
+
+class ConfigHandler(BaseHandler):
+    def get(self, camera_id=None, op=None):
+        if op == 'get':
+            self.get_config(camera_id)
+        
+        else:
+            raise HTTPError(400, 'unknown operation')
+    
+    def post(self, camera_id=None, op=None):
+        if op == 'set':
+            self.set_config(camera_id)
+        
+        elif op == 'add':
+            self.add_camera()
+        
+        elif op == 'rem':
+            self.rem_camera(camera_id)
+        
+        else:
+            raise HTTPError(400, 'unknown operation')
+    
+    def get_config(self, camera_id):
+        logging.debug('getting config for camera %(id)s' % {'camera': camera_id})
+    
+    def set_config(self, camera_id):
+        logging.debug('setting config for camera %(id)s' % {'camera': camera_id})
+    
+    def add_camera(self):
+        logging.debug('adding new camera')
+    
+    def rem_camera(self, camera_id):
+        logging.debug('removing camera %(id)s' % {'camera': camera_id})
+
+
+class SnapshotHandler(BaseHandler):
+    def get(self, camera_id, op, filename=None):
+        if op == 'current':
+            self.current()
+            
+        elif op == 'list':
+            self.list(camera_id)
+            
+        elif op == 'download':
+            self.download(filename)
+        
+        else:
+            raise HTTPError(400, 'unknown operation')
+    
+    def current(self):
+        pass
+    
+    def list(self, camera_id):
+        logging.debug('listing snapshots for camera %(id)s' % {'camera': camera_id})
+    
+    def download(self, camera_id, filename):
+        logging.debug('downloading snapshot %(filename)s of camera %(id)s' % {
+                'filename': filename, 'camera': camera_id})
+
+
+class MovieHandler(BaseHandler):
+    def get(self, camera_id, op, filename=None):
+        if op == 'list':
+            self.list(camera_id)
+            
+        elif op == 'download':
+            self.download(camera_id, filename)
+        
+        else:
+            raise HTTPError(400, 'unknown operation')
+    
+    def list(self, camera_id):
+        logging.debug('listing movies for camera %(id)s' % {'camera': camera_id})
+    
+    def download(self, camera_id, filename):
+        logging.debug('downloading movie %(filename)s of camera %(id)s' % {
+                'filename': filename, 'camera': camera_id})
index 6c5507c748803df15ef82695191e02b51adcacff..8d7b86bf8d24b380d08f0a1e15fbb99731fe2dc5 100644 (file)
@@ -9,6 +9,12 @@ import template
 application = Application(
     [
         (r'^/$', handlers.MainHandler),
+        (r'^/config/(?P<camera_id>\w+)/(?P<op>get|set|rem)/?$', handlers.ConfigHandler),
+        (r'^/config/(?P<op>add)/?$', handlers.ConfigHandler),
+        (r'^/snapshot/(?P<camera_id>\w+)/(?P<op>current|list)/?$', handlers.SnapshotHandler),
+        (r'^/snapshot/(?P<camera_id>\w+)/(?P<op>download)/(?P<filename>.+)/?$', handlers.SnapshotHandler),
+        (r'^/movie/(?P<camera_id>\w+)/(?P<op>list)/?$', handlers.MovieHandler),
+        (r'^/movie/(?P<camera_id>\w+)/(?P<op>download)/(?P<filename>.+)/?$', handlers.MovieHandler),
     ],
     debug=settings.DEBUG,
     static_path=settings.STATIC_PATH,
diff --git a/temp/.gitkeep b/temp/.gitkeep
new file mode 100644 (file)
index 0000000..18d93d2
--- /dev/null
@@ -0,0 +1 @@
+this directory contains (at runtime) temporary config files for motion
\ No newline at end of file