Allow for creation of site using any package
Committed bef015
--- a/pyproject.toml
+++ b/pyproject.toml
+[build-system]
+requires = ["poetry-core>=1.0.0"]
+build-backend = "poetry.core.masonry.api"
+
[tool.poetry]
name = "webint-sites"
version = "0.0.2"
license = "AGPL-3.0-or-later"
packages = [{include="webint_sites"}]
+[tool.pyright]
+reportGeneralTypeIssues = false
+reportOptionalMemberAccess = false
+
[tool.poetry.plugins."webapps"]
sites = "webint_sites:app"
+[[tool.poetry.source]]
+name = "main"
+url = "https://ragt.ag/code/pypi"
+
[tool.poetry.dependencies]
python = ">=3.10,<3.11"
webint = ">=0.0"
webagt = {path="../webagt", develop=true}
webint = {path="../webint", develop=true}
micropub = {path="../python-micropub", develop=true}
-
-# [[tool.poetry.source]]
-# name = "main"
-# url = "https://ragt.ag/code/pypi"
-
-[tool.pyright]
-reportGeneralTypeIssues = false
-reportOptionalMemberAccess = false
-
-[build-system]
-requires = ["poetry-core>=1.0.0"]
-build-backend = "poetry.core.masonry.api"
--- a/webint_sites/__init__.py
+++ b/webint_sites/__init__.py
model={
"machines": {
"name": "TEXT UNIQUE",
+ "package": "TEXT UNIQUE",
+ "app": "TEXT UNIQUE",
"ip_address": "TEXT UNIQUE",
"details": "JSON",
},
)
-def spawn_machine(name, config):
+def spawn_machine(name, package, app, config):
"""Spin up a VPS and setup a machine."""
- machine, secret = web.host.setup_website(
- name, "canopy-platform", "canopy:app", config
- )
+ machine, secret = web.host.setup_website(name, package, app, config)
print(machine, secret)
tx.db.insert("machines", name=name, ip_address=machine.address, details={})
return app.view.machines()
def post(self):
- name = web.form("name").name
+ form = web.form("name", "package", "app")
config = {
"host": "digitalocean",
"host_token": tx.app.cfg["DIGITALOCEAN_TOKEN"],
# token = tx.db.select(
# "providers", where="service = ?", vals=["digitalocean.com"]
# )[0]["token"]
- web.enqueue(spawn_machine, name, config)
+ web.enqueue(spawn_machine, form.name, form.package, form.app, config)
raise web.Accepted("machine is being created..")
--- a/webint_sites/templates/index.html
+++ b/webint_sites/templates/index.html
<form method=post action=/sites/machines>
<label><small>Name</small><br>
<label class=bounding><input type=text name=name></label></label>
+ <input type=hidden name=package value=canopy-platform>
+ <input type=hidden name=app value=canopy:app>
<div class=buttons><button>Spawn Machine</button></div>
</form>
$else: