Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -389,3 +389,23 @@ def main():
|
|
389 |
|
390 |
if __name__ == "__main__":
|
391 |
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
|
390 |
if __name__ == "__main__":
|
391 |
main()
|
392 |
+
|
393 |
+
|
394 |
+
from flask import Flask, request, jsonify
|
395 |
+
|
396 |
+
app = Flask(__name__)
|
397 |
+
|
398 |
+
@app.route('/terminal', methods=['POST'])
|
399 |
+
def terminal():
|
400 |
+
command = request.json.get('command')
|
401 |
+
if not command:
|
402 |
+
return jsonify({'error': 'No command provided'}), 400
|
403 |
+
|
404 |
+
try:
|
405 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
406 |
+
return jsonify({'output': result.stdout, 'error': result.stderr})
|
407 |
+
except Exception as e:
|
408 |
+
return jsonify({'error': str(e)}), 500
|
409 |
+
|
410 |
+
if __name__ == '__main__':
|
411 |
+
app.run(port=5000)
|