コード例 #1
0
 def get(self):
     if database.getSettings()["isHub"] == True:
         if self.get_secure_cookie("user"):
             userInfo = database.getUser(self.get_secure_cookie("user").decode("utf-8"))
             # Only serve settings page to admin users
             if userInfo and userInfo.isAdmin:
                 settings = database.getSettings()
                 self.render("web/settings.html", settings=settings)
                 return
         self.redirect("/login")
コード例 #2
0
    def post(self):
        if database.getSettings()["isHub"] == True:
            if self.get_secure_cookie("user"):
                userInfo = database.getUser(self.get_secure_cookie("user").decode("utf-8"))
                # Only change settings if user is admin
                if userInfo and userInfo['isAdmin']:
                    settings = database.getSettings()
                    for arg in self.request.arguments.keys():
                        settings[arg] = self.request.arguments[arg][0].decode("utf-8")

                    database.saveSettings(settings)
                    self.redirect('/')
                    return
            self.redirect('/login')
コード例 #3
0
def main():
    port = int(database.getSettings()["port"])
    app = make_app()
    app.listen(port)
    print("Starting web application on port %s" % port)
    signal.signal(signal.SIGINT, signalHandler)
    tornado.ioloop.IOLoop.current().start()
コード例 #4
0
 def post(self):
     if database.getSettings()["isHub"] == True:
         username = self.get_argument("username")
         password = self.get_argument("password")
         if username != "" and password != "":
             #If user information was correct give them a secure cookie so we can identify what user they are later.
             if raspcam.database.userCheck(username, password):
                 self.set_secure_cookie("user", username)
                 print("Login successful for user %s" % username)
                 self.redirect("/")
                 return
         print("Failed login attempt for user %s" % username)
         self.redirect("/login")
コード例 #5
0
    def post(self, page):
        if database.getSettings()["isHub"] == True:
            camName = self.get_argument("cameraName")
            ip = self.get_argument("ip")
            port = self.get_argument("port")

            if camName and ip and port:
                location = '%s:%s/feed/' % (ip, port,)
                database.createCamera(camName, location, 0, str(uuid.uuid4()))
                print("New camera location added")
                self.redirect('/')
                return
            self.redirect("/camera/new")
コード例 #6
0
 def get(self, page):
     settings = database.getSettings()
     if page == 'ishub':
         settings["isHub"] = True
         settings["setup"] = False
         database.saveSettings(settings)
     elif page == "isextra":
         settings["isHub"] = False
         settings["setup"] = False
         database.saveSettings(settings)
     else:
         self.render('web/firststart.html')
         return
     self.redirect('/camera/')
コード例 #7
0
    def get(self):
        # Make sure the user is logged in
        #if not self.get_secure_cookie("user"):
        #    self.redirect("/login")
        #    return

        settings = database.getSettings()

        user = database.getUser(self.get_secure_cookie("user").decode("utf-8")) if self.get_secure_cookie("user") != None else None

        if settings['setup'] == True:
            self.redirect("/firststart/")
        elif settings["isHub"] == True:
            # grab camera details and split them into arrays of two for visual purposes
            cameras = database.getCameras()
            if user:
                cameras.append({'name':'_addCam'}) # todo: better solution :p
            cameras = [cameras[i:i + 2] for i in range(0, len(cameras), 2)]
            self.render("web/index.html", cameras=cameras, user=user)
コード例 #8
0
 def get(self):
     if database.getSettings()["isHub"] == True:
         self.render("web/login.html")
コード例 #9
0
 def get(self, page):
     if page == "new" and database.getSettings()["isHub"] == True:
         self.render('web/newcamera.html')
     else:
         self.render("web/camera.html")