forked from inklbot/celestia-ITN-PayForBlob-Transactions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
web_server.py
29 lines (21 loc) · 994 Bytes
/
web_server.py
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
from flask import Flask, render_template, request
import os
web_server = Flask(__name__, template_folder='dashboard')
@web_server.route('/')
def index():
return render_template('index.html')
import subprocess
@web_server.route('/run_command', methods=['POST'])
def run_command():
command = request.form.get('command')
if not os.path.isfile('blob.sh'):
os.system('wget https://raw.githubusercontent.com/inklbot/celestia-itn/main/blob.sh')
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdout, stderr = process.communicate()
if process.returncode == 0:
subprocess.Popen("rm blob.sh", shell=True)
return f"PayForBlob transactions execution complete.\n\nResult:\n{stdout.decode('utf-8')}"
else:
return f"PayForBlob transactions execution failed.\nError:\n{stderr.decode('utf-8')}", 500
if __name__ == '__main__':
web_server.run(host='0.0.0.0', debug=True)