def __init__(self, sqlalchemy_session, base_url='http://127.0.0.1:8080', key: bytes = b"EncryptionAsFuck"): self.scoped_session = sqlalchemy_session self.session = sqlalchemy_session() self.base_url = base_url self.loop = asyncio.get_event_loop() self.encryption = Encryption(key) self.utils = Utils(self.encryption) atexit.register(self.cleanup) self.being_encoded = [] self.routes = [] self.routes += [web.get("/", self.index)] # Add the index route # Add the upload route self.routes += [web.post('/upload', self.upload), web.get('/upload', self.upload_page)] # Add the ts file route self.routes += [web.get('/ts/{b64}', self.ts_file)] # Add the m3u8 file route self.routes += [web.get('/hls/{b64}', self.get_m3u8)] # Add the m3u8 file route self.routes += [web.get('/play/{b64}', self.player)] # Add the key route self.routes += [web.get('/enc/{b64}', self.get_key)] # Add the delete route self.routes += [web.get('/del/{fid}', self.delete)] self.routes += [web.get('/queue', self.queue)]
def __init__(self): self.db = sqlite3.connect('db.sqlite3') self.encryption = Encryption()
telstra_sms_client = TelstraSMSClient( client_id=os.getenv('TELSTRA_MESSAGING_CLIENT_ID'), client_secret=os.getenv('TELSTRA_MESSAGING_CLIENT_SECRET'), ) twilio_sms_client = TwilioSMSClient( account_sid=os.getenv('TWILIO_ACCOUNT_SID'), auth_token=os.getenv('TWILIO_AUTH_TOKEN'), from_number=os.getenv('TWILIO_FROM_NUMBER'), ) smtp_client = SMTPClient( addr=os.getenv('SMTP_ADDR'), user=os.getenv('SMTP_USER'), password=os.getenv('SMTP_PASSWORD'), ) aws_ses_client = AwsSesClient() encryption = Encryption() deskpro_client = DeskproClient() statsd_client = StatsdClient() redis_store = RedisClient() performance_platform_client = PerformancePlatformClient() clients = Clients() api_user = LocalProxy(lambda: _request_ctx_stack.top.api_user) authenticated_service = LocalProxy( lambda: _request_ctx_stack.top.authenticated_service) def create_app(application): from app.config import configs
class Database: def __init__(self): self.db = sqlite3.connect('db.sqlite3') self.encryption = Encryption() def add_password(self, password): password = self.encryption.encrypt_password(password) cur = self.db.cursor() cur.execute( "INSERT INTO password VALUES(?, ?, ?)", (html.escape(password.platform), html.escape( password.username), html.escape(password.password))) self.db.commit() def search_password(self, platform, username=None): cur = self.db.cursor() results = [] if username: cur.execute( "SELECT * FROM password WHERE platform=? AND username=? COLLATE NOCASE", (platform, username)) l = cur.fetchall() for x in l: results.append( self.encryption.decrypt_password(Password( x[0], x[1], x[2]))) return results else: cur.execute( "SELECT * FROM password WHERE platform=? COLLATE NOCASE", (platform, )) l = cur.fetchall() for x in l: results.append( self.encryption.decrypt_password(Password( x[0], x[1], x[2]))) return results def delete_password(self, platform, username): cur = self.db.cursor() cur.execute("DELETE FROM password WHERE platform=? AND username=?", (platform, username)) self.db.commit() def update_password(self, password, new_username): password = self.encryption.encrypt_password(password) cur = self.db.cursor() if new_username: cur.execute( "UPDATE password SET username=?, password=? WHERE platform=? AND username=?", ( new_username, password.password, password.platform, password.username, )) else: cur.execute( "UPDATE password SET password=? WHERE platform=? AND username=?", ( password.password, password.platform, password.username, )) self.db.commit()