Skip to content

Commit

Permalink
Added link
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacg1 committed Dec 23, 2014
1 parent 45189ef commit 9de3bef
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<body>
<h3> Pyth Compiler/Executor </h3>""")
<h3> <ahref="https://github.com/isaacg1/pyth">Pyth</a>
Compiler/Executor </h3>""")

form = cgi.FieldStorage()
code_message = form.getvalue("code", "")
Expand All @@ -29,11 +30,18 @@
debug_on = False

pyth_code = code_message.split("\r\n")[0]
pyth_process = subprocess.Popen(["/usr/bin/python3", "safe_pyth.py","-cd" if debug_on else "-c", pyth_code],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output, errors = pyth_process.communicate(input=bytearray(input_message,'utf-8'))
pyth_process =
subprocess.Popen(["/usr/bin/python3",
"safe_pyth.py",
"-cd" if debug_on else "-c",
pyth_code],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
output, errors =
pyth_process.communicate(input=bytearray(input_message, 'utf-8'))
if code_message:
print("<p>Output:</p>")
print("<p>Output:</p>")

print("<pre>")
for line in output.decode().split('\n'):
Expand All @@ -51,8 +59,8 @@
print("""</pre>
<form id="code_input" method="post" action="index.py">
<p><input type="submit" value="Run!" style="background-color: #00FFFF"/></p>
<p>Debug on?: <input type="checkbox" name="debug"/></p>
<p><input type="submit" value="Run!" style="background-color: #00FFFF"/></p>
<p>Debug on?: <input type="checkbox" name="debug"/></p>
</form>
<p>Code:</p>
Expand All @@ -68,4 +76,7 @@
</body>
</html>
""".format(cgi.escape(code_message), len(code_message), cgi.escape(input_message), formatted_time))
""".format(cgi.escape(code_message),
len(code_message),
cgi.escape(input_message),
formatted_time))

0 comments on commit 9de3bef

Please sign in to comment.