aboutsummaryrefslogtreecommitdiffstats
path: root/snekbox.py
diff options
context:
space:
mode:
authorGravatar Mark <[email protected]>2019-03-28 21:08:54 -0700
committerGravatar GitHub <[email protected]>2019-03-28 21:08:54 -0700
commit94b5ea60fd823ae2d69b339f39d686959c6791de (patch)
tree028996ba83a000272f05b00f1d974b0942078749 /snekbox.py
parentReplace RMQ with a POST endpoint (#7) (diff)
parentRestructure project layout (diff)
Merge pull request #15 from python-discord/refactor/restructure
Restructure the Project Layout
Diffstat (limited to '')
-rw-r--r--snekbox/nsjail.py (renamed from snekbox.py)42
1 files changed, 2 insertions, 40 deletions
diff --git a/snekbox.py b/snekbox/nsjail.py
index 65fc4b3..458a94e 100644
--- a/snekbox.py
+++ b/snekbox/nsjail.py
@@ -2,11 +2,9 @@ import os
import subprocess
import sys
-from flask import Flask, jsonify, render_template, request
-
-class Snekbox:
- """Core snekbox functionality, providing safe execution of Python code."""
+class NsJail:
+ """Core Snekbox functionality, providing safe execution of Python code."""
def __init__(self,
nsjail_binary='nsjail',
@@ -95,39 +93,3 @@ class Snekbox:
return 'unknown error, no error code'
return output
-
-
-snekbox = Snekbox()
-
-# Load app
-app = Flask(__name__)
-app.use_reloader = False
-
-# Logging
-log = app.logger
-
-
-def index():
- """Return a page with a form for inputting code to be executed."""
-
- return render_template('index.html')
-
-
[email protected]('/result', methods=["POST", "GET"])
-def result():
- """Execute code and return a page displaying the results."""
-
- if request.method == "POST":
- code = request.form["Code"]
- output = snekbox.python3(code)
- return render_template('result.html', code=code, result=output)
-
-
[email protected]('/input', methods=["POST"])
-def code_input():
- """Execute code and return the results."""
-
- body = request.get_json()
- output = snekbox.python3(body["code"])
- return jsonify(input=body["code"], output=output)