This file contains hidden or 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
# https://docs.python.org/2/library/logging.config.html | |
# https://docs.python.org/3.6/library/logging.config.html | |
import logging | |
import logging.config | |
import datetime | |
DEFAULT_LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, |
This file contains hidden or 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
for line in iter(lambda: input('> '), 'exit'): | |
print(eval(line)) |
This file contains hidden or 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 | |
from twisted.web.static import File | |
from twisted.python import log | |
from twisted.web.server import Site | |
from twisted.internet import reactor | |
log.startLogging(sys.stdout) | |
root = File('.') | |
site = Site(root) | |
reactor.listenTCP(8080, site) |
This file contains hidden or 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 | |
from twisted.web.static import File | |
from twisted.python import log | |
from twisted.web.server import Site | |
from twisted.internet import reactor | |
from autobahn.twisted.websocket import WebSocketServerFactory, \ | |
WebSocketServerProtocol | |
from autobahn.twisted.resource import WebSocketResource |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
// use vanilla JS because why not | |
window.addEventListener("load", function() { | |
// create websocket instance | |
var mySocket = new WebSocket("ws://localhost:8080/ws"); | |
This file contains hidden or 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
def decorator(f): | |
@functools.wraps(f) | |
def wrapper(*args, **kwargs): | |
print('Wrapping') | |
return f(*args, **kwargs) | |
return wrapper | |
@decorator | |
def f(): | |
print('Function f') |