-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
71 lines (53 loc) · 1.59 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
echo "### Krok 1: Usuwanie istniejących kontenerów i obrazów Dockera ###"
docker-compose down
docker system prune -a -f
echo "### Krok 2: Tworzenie struktury katalogów ###"
mkdir -p my_project/app/templates my_project/tests
echo "### Krok 3: Aktualizacja plików ###"
cat > my_project/app/__init__.py <<EOL
from flask import Flask
def create_app():
app = Flask(__name__)
app.config.from_object('app.config.Config')
from .main import main as main_blueprint
app.register_blueprint(main_blueprint)
return app
EOL
cat > my_project/app/config.py <<EOL
class Config:
SECRET_KEY = 'supersecretkey'
EOL
cat > my_project/app/main.py <<EOL
from flask import Blueprint, request, jsonify
import subprocess
main = Blueprint('main', __name__)
@main.route('/chat', methods=['POST'])
def chat():
data = request.json
message = data.get('message')
response = f"I received your message: {message}"
return jsonify({'response': response})
@main.route('/execute', methods=['POST'])
def execute():
data = request.json
command = data.get('command')
result = subprocess.run(command, shell=True, capture_output=True, text=True)
return jsonify({'output': result.stdout})
EOL
cat > my_project/app/requirements.txt <<EOL
Flask==2.1.1
Werkzeug==2.0.3
EOL
cat > my_project/app/wsgi.py <<EOL
from app import create_app
app = create_app()
if __name__ == "__main__":
app.run()
EOL
cat > my_project/app/templates/index.html <<EOL
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">