1import subprocess
2
3from flask import Flask
4app = Flask(__name__)
5
6def run_command(command):
7 return subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read()
8
9@app.route('/<command>')
10def command_server(command):
11 return run_command(command)
12
13# Then run in server:
14# export FLASK_APP=server.py
15# flask run
16
17# You can run the below command insteed of the above to make public your server
18# flask run --host=0.0.0.0