Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (29 sloc) 1.02 KB
import flask
import subprocess
proxy = flask.Flask(__name__)
@proxy.route("/init", methods=[ "POST" ])
def init():
return flask.jsonify(ok=True)
@proxy.route("/run", methods=[ "POST" ])
def run():
msg = flask.request.get_json(force=True, silent=True)
if not msg or not isinstance(msg, dict):
r = flask.jsonify({ "error": "Invalid payload." })
r.status_code = 400
return r
input_string = msg.get("value", {}).get("input", {})
with open("/root/dos/INPUT.STR", "w") as fp:
fp.write("\"%s\"\n" % input_string)[
"dosbox", "./PRINT.EXE", "-c", "C:\\QBASIC.EXE /run C:\\MORSE.BAS > C:\\LOG.TXT", "-exit"
], cwd="/root/dos")
output = "???"
with open("/root/dos/LOG.TXT", "r") as fp:
output =
except e:
return flask.jsonify(input=input_string, output=output)
if __name__ == "__main__":'', port=8080)