Created
April 5, 2021 12:54
-
-
Save chrisjsimpson/2d96d9afd01fb7cbb3a7cde134817728 to your computer and use it in GitHub Desktop.
poor mans aws
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment