This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Blueprint, jsonify | |
from sse import sse | |
# required line at the top of every blueprint file | |
api = Blueprint("api", __name__) # match variable name and first arg to file name | |
# register more blueprints here to further split up the api | |
# e.g. | |
# api.register_blueprint(blueprint, url_prefix='/users') | |
# would cascade through /api/users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Blueprint, jsonify | |
# required line at the top of every blueprint file | |
api = Blueprint("api", __name__) # match variable name and first arg to file name | |
# register more blueprints here to further split up the api | |
# e.g. | |
# api.register_blueprint(blueprint, url_prefix='/users') | |
# would cascade through /api/users | |
# api routes when hitting /api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
from Crypto.PublicKey import RSA | |
from Crypto.Cipher import PKCS1_v1_5 | |
# pass in the public key of the client to communicate with | |
class Crypt: | |
def __init__(self): | |
# 1024 means the keysize will be 1024 bits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
from watchdog.observers import Observer | |
from watchdog.events import FileSystemEventHandler | |
class Watcher: | |
def __init__(self, path="", on_created=None, on_deleted=None, on_modified=None, on_moved=None): | |
self.event_handler = FileSystemEventHandler() | |
self.observer = Observer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto import Random | |
from Crypto.Cipher import AES | |
import base64 | |
from hashlib import md5 | |
BLOCK_SIZE = 16 | |
class CryptoWrapper: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from base64 import b64encode, b64decode | |
from Crypto.Cipher import AES | |
from Crypto.Util.Padding import pad, unpad | |
class CryptoWrapper: | |
def __init__(self, key): | |
self.key = (key * 2).encode() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
window.onload = function() { | |
var connection = new WebSocket("ws://localhost:9876/"); | |
connection.onopen = function () { | |
connection.send('hello world'); | |
}; | |
connection.onerror = function (error) { | |
console.log('WebSocket Error ' + error); | |
}; |