root commited on
Commit
ed9a284
·
1 Parent(s): f154603

Add application file

Browse files
Files changed (3) hide show
  1. Dockerfile +17 -0
  2. app.py +25 -0
  3. requirements.txt +1 -0
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Используем базовый образ Python
2
+ FROM python:3.9-slim
3
+
4
+ # Устанавливаем рабочую директорию
5
+ WORKDIR /app
6
+
7
+ # Копируем файлы проекта
8
+ COPY . .
9
+
10
+ # Устанавливаем зависимости
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Открываем порт
14
+ EXPOSE 5000
15
+
16
+ # Запускаем приложение
17
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from flask import Flask, request, jsonify
3
+
4
+ app = Flask(__name__)
5
+
6
+ @app.route('/execute', methods=['POST'])
7
+ def execute_command():
8
+ data = request.json
9
+ command = data.get('command')
10
+
11
+ if not command:
12
+ return jsonify({"error": "No command provided"}), 400
13
+
14
+ try:
15
+ result = subprocess.run(command, shell=True, capture_output=True, text=True)
16
+ return jsonify({
17
+ "stdout": result.stdout,
18
+ "stderr": result.stderr,
19
+ "returncode": result.returncode
20
+ })
21
+ except Exception as e:
22
+ return jsonify({"error": str(e)}), 500
23
+
24
+ if __name__ == '__main__':
25
+ app.run(host='0.0.0.0', port=5000)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ flask