Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
5063-Labs/Sandbox/Development/opt/app.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44 lines (32 sloc)
862 Bytes
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
""" | |
Very simple Flask App. For Testing | |
""" | |
import sys | |
import flask | |
from flask_socketio import SocketIO | |
import logging | |
log = logging.getLogger("APP") | |
app = flask.Flask(__name__) | |
socketio = SocketIO(app) | |
@app.route('/', methods=["GET","POST"]) | |
def main(): | |
return flask.render_template('index.html') | |
@socketio.on("connect") | |
def connect(): | |
version = sys.version | |
socketio.send("Python {0}".format(version)) | |
@socketio.on('message') | |
def handle_message(message): | |
try: | |
out = eval(message) | |
if type(out) == bytes: | |
socketio.send(out.decode()) | |
else: | |
socketio.send(out) | |
except Exception as ex: | |
socketio.send("{}".format(ex)) | |
@app.route('/debug') | |
def debug(): | |
return flask.Response(open(__file__).read(), mimetype='text/plain') | |
if __name__ == "__main__": | |
socketio.run(app) |