Skip to content

Instantly share code, notes, and snippets.

@chrisjsimpson
Created April 5, 2021 12:54
Show Gist options
  • Save chrisjsimpson/2d96d9afd01fb7cbb3a7cde134817728 to your computer and use it in GitHub Desktop.
Save chrisjsimpson/2d96d9afd01fb7cbb3a7cde134817728 to your computer and use it in GitHub Desktop.
poor mans aws
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