|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<!-- Required meta tags --> |
| 5 | +<meta charset="utf-8"> |
| 6 | +<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 7 | + |
| 8 | +<!-- Bootstrap CSS --> |
| 9 | +<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> |
| 10 | +<title>Hello, world!</title> |
| 11 | +</head> |
| 12 | +<body> |
| 13 | + <div class="container"> |
| 14 | + <div class="row"> |
| 15 | + <div class="col-sm-12"> |
| 16 | + <div class="jumbotron"> |
| 17 | + <h1 class="display-4">Create a server quickly</h1> |
| 18 | + <p class="lead">You get a server with an ipv6 public address, which you can login to using ssh.</p> |
| 19 | + <hr class="my-4"> |
| 20 | + <p><em>You can also create a server using curl:</em><br /> |
| 21 | + <span style="background:white; padding: 4px;">curl {{ request.host_url }}container -d '{"hostname":123, "memory": 1024, "ssh_public_keys": "<string-of-your-public-key>", "network": {}}'</span></p> |
| 22 | + <a href="/openapi">View Openapi</a> |
| 23 | + </div> |
| 24 | + </div> |
| 25 | + </div> |
| 26 | + |
| 27 | + <div class="row" id="start"> |
| 28 | + <div class="col-sm-12"> |
| 29 | + <form action="#" method="POST" id="serverForm"> |
| 30 | + <div class="form-group"> |
| 31 | + <label for="hostname">Hostname</label> |
| 32 | + <input type="hostname" name="hostname" class="form-control" id="hostname" placeholder="example.com" aria-describedby="hostnameHelp" required> |
| 33 | + <small id="hostnameHelp" class="form-text text-muted">e.g. example.com</small> |
| 34 | + </div> |
| 35 | + <div class="form-group">Ram |
| 36 | + <label for="exampleInput1">Ram</label> |
| 37 | + <input type="number" name="memory" step="1" class="form-control" value="1024" id="exampleInputRam1" disabled> |
| 38 | + <small class="form-text text-muted">You can increase this later.</small> |
| 39 | + </div> |
| 40 | + <div class="form-group"> |
| 41 | + <label for="ssh_public_keys">Public SSH Key (so you can login)</label> |
| 42 | + <textarea class="form-control" name="ssh_public_keys" id="ssh_public_keys" rows="3" Required |
| 43 | + placeholder="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC71TlW7HzAUkiLN7GuP6p/IRivXxu0nXvhE4snnKxwpaWod8jPUJCYb8ISt4hhmuGCzHSKz4piOtdYHHUiaLWPZHGTUlkwCqbTYlfiz+YxWsF117I8iOjLGQuqn6f1pgZA+BE7YB2l3sUPNwBoCr5yyycIENFR6euDbCym0kODFhIQA5j2FyMI5QuwXWKj8P4t/pthBgqyyUsah47q51IWz7FVTHup4FIj/JPgqu/X/ZEkH+DHh8qv7kwl5uSBb6evctv7JqqNz2xbGCli+dDLvL0zgsFtPLjycK/KUN5qWHTjNvpE/CPzat2InI4wXYuX11Y9Dfah+jMrR7mb+ahRu0Zbvsn/RIpybgydMahBVYs1SAFtmzbGnnJODlag7vr2D/Jdi3E0LPliPqGQB3zCAINaQ00BAHg4ERxK4eS4TGOmqQVSYG4Y+8YhOBtEcvIGTA5/kfjAL/o69oUsC6x+tWPlzGFB5kQkS2ALs1C+S97F1Iu2yx45ZPfSmdtgGr0= bob@example"></textarea> |
| 44 | + <small class="form-text text-muted">Don't know what this is? It's better than a password. <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key" target="_blank">How to generate an ssh key</a></small> |
| 45 | + </div> |
| 46 | + <button type="submit" id="save" class="btn btn-primary btn-lg" href="#start" role="button">Start a Server</button> |
| 47 | + </form> |
| 48 | + </div> |
| 49 | + </div> |
| 50 | + </div><!-- end container --> |
| 51 | + |
| 52 | +<!-- Optional JavaScript --> |
| 53 | +<!-- jQuery first, then Popper.js, then Bootstrap JS --> |
| 54 | +<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"> |
| 55 | +</script> |
| 56 | +<script src=" https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity=" sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin=" anonymous" > |
| 57 | +</script> |
| 58 | +<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"> |
| 59 | +</script> |
| 60 | +<script> |
| 61 | +form = document.getElementById('save'); |
| 62 | + |
| 63 | +form.addEventListener("click", function(e) { |
| 64 | + e.preventDefault(); |
| 65 | + console.log("OK"); |
| 66 | + form.innerText = "Starting server..." |
| 67 | + form.disabled = true; |
| 68 | + |
| 69 | + const formData = new FormData(document.getElementById('serverForm')); |
| 70 | + var object = {}; |
| 71 | + formData.forEach((value, key) => object[key] = value); |
| 72 | + |
| 73 | + object['memory'] = 512 |
| 74 | + object['network'] = {} |
| 75 | + |
| 76 | + var json = JSON.stringify(object); |
| 77 | + fetch('http://another-web-service.pcpink.co.uk/container', { |
| 78 | + method: 'POST', |
| 79 | + body: json |
| 80 | + }) |
| 81 | + .then(response => response.json()) |
| 82 | + .then(data => { |
| 83 | + console.log('Success:', data); |
| 84 | + document.write(data.msg); |
| 85 | + }) |
| 86 | + .catch((error) => { |
| 87 | + console.error('Error:', error); |
| 88 | + }); |
| 89 | + |
| 90 | +}) |
| 91 | +</script> |
| 92 | +</body> |
| 93 | +</html> |
| 94 | + |
0 commit comments