def __init__(self): """Adds arguements to the request. Verify a user's key, and connects to the database.""" password = Database.getPassword() parser = reqparse.RequestParser() parser.add_argument("con1", type=str) parser.add_argument("key", type=str, location="headers") parser.add_argument("user", type=str, location="headers") self.parsed = parser.parse_args() key, user = self.parsed["key"], self.parsed["user"] if key == None or user == None: abort(406, message="Either the key, or user field is left blank.") Key().verifyKey(user, key) """A redirect table of some sort is needed. Refer to testing.redirect for a guide.""" try: self.conn, self.cursor = Database.connect("localhost", "root", password[0], "testing") self.schema = "testing" except Exception: self.conn, self.cursor = Database.connect("localhost", "root", password[1], "tsc_office") self.schema = "tsc_office"
def __init__(self): """Handles initialization, and connects to the database""" password = Database.getPassword() try: self.conn, self.cursor = Database.connect("localhost", "root", password[0], "testing") self.schema = "testing" self.table = "images" except Exception: self.conn, self.cursor = Database.connect("localhost", "root", password[1], "tsc_office") self.schema = "tsc_office" self.table = "timages" parser = reqparse.RequestParser() parser.add_argument("image", type=FileStorage, location="files") self.parsed = parser.parse_args() try: path = "../src/images/" os.chdir(path) print("CHANGED PATH") except Exception: pass
def __init__(self): password = Database.getPassword() self.schema = "tsc_office" try: self.conn, self.cursor = Database.connect("localhost", "root", password[0], self.schema) except Exception: self.conn, self.cursor = Database.connect("localhost", "root", password[1], self.schema) parser = reqparse.RequestParser() parser.add_argument("key", type=str, location='headers') parser.add_argument("user", type=str, location='headers') parsed = parser.parse_args() key, user = parsed["key"], parsed["user"] Key().verifyKey(user, key)