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
// This source code is taken from Firefox Send (https://github.com/mozilla/send) and slightly modified. | |
export default async function saveFile(plaintext: ArrayBuffer, fileName: string, fileType: string) { | |
return new Promise((resolve, reject) => { | |
const dataView = new DataView(plaintext); | |
const blob = new Blob([dataView], { type: fileType }); | |
if (navigator.msSaveBlob) { | |
navigator.msSaveBlob(blob, fileName); | |
return resolve(); |
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
#!/usr/bin/env python | |
# Usage: python cors_http_server.py <port> | |
try: | |
# try to use Python 3 | |
from http.server import HTTPServer, SimpleHTTPRequestHandler, test as test_orig | |
import sys | |
def test (*args): | |
test_orig(*args, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000) |
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
#!/usr/bin/env python | |
from sys import argv | |
import BaseHTTPServer | |
import ssl | |
class CORSHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |
def do_OPTIONS(self): | |
self.send_response(200, "ok") | |
#self.send_header('Access-Control-Allow-Origin', '*') |
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
# useful for running ssl server on localhost | |
# which in turn is useful for working with WebSocket Secure (wss) | |
# copied from http://www.piware.de/2011/01/creating-an-https-server-in-python/ |
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
# adapated from http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
# generate seperate key+crt files, make sure common name (CN) == ip or hostname | |
# openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout newkey.key -out newkey.crt | |
# run as follows: | |
# python simple-https-server.py | |
import BaseHTTPServer, SimpleHTTPServer | |
import ssl | |
# 0.0.0.0 allows connections from anywhere |