import subprocess from random import randrange from flask import Flask def create_app(): app = Flask(__name__) @app.route('/') def create_container(): container_id = randrange(1000,9000) command = f"pct create {container_id} --start --hostname {container_id} --net0 name=eth0,bridge=vmbr0,ip6=dhcp,gw6=2a01:4f8:160:2333:0:1:0:2 --memory 10240 local:vztmpl/debian-10-standard_10.7-1_amd64.tar.gz" subprocess.run(command, shell=True) return f"Container created, probably. With container_id: {container_id}" return app """ Run with: gunicorn -w 4 -b 0.0.0.0:4000 "app:create_app()" --daemon """