this solves issues 2 & 3
This commit is contained in:
parent
767f0e8bf5
commit
2c5800b945
12
index.js → app.js
Executable file → Normal file
12
index.js → app.js
Executable file → Normal file
@ -2,6 +2,7 @@ const axios = require('axios');
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const port = 3000
|
||||
const path = require('path');
|
||||
|
||||
async function resetvm(vmid){
|
||||
try {
|
||||
@ -18,7 +19,14 @@ async function resetvm(vmid){
|
||||
}
|
||||
}
|
||||
|
||||
app.get('/:id', async (req, res) => {
|
||||
|
||||
app.use('/static', express.static(path.join(__dirname, 'static')));
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
res.sendFile(path.join(__dirname, '/static/index.html'));
|
||||
});
|
||||
|
||||
app.post('/:id', async (req, res) => {
|
||||
let apiCall = await resetvm(req.params.id)
|
||||
if(apiCall){
|
||||
res.send(`the vm ${req.params.id} has been reset`)
|
||||
@ -28,5 +36,5 @@ app.get('/:id', async (req, res) => {
|
||||
})
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening on port ${port}`)
|
||||
console.log(`App listening on port ${port}`)
|
||||
})
|
17
static/index.html
Normal file
17
static/index.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<title>Page Title</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="">
|
||||
<style></style>
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||
<script src="./static/index.js"></script>
|
||||
<body>
|
||||
|
||||
<button id="reset">RESET</button>
|
||||
<div id="result"></div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
7
static/index.js
Executable file
7
static/index.js
Executable file
@ -0,0 +1,7 @@
|
||||
$(document).ready(function(){
|
||||
$('#reset').on('click', function(){
|
||||
$.post("http://localhost:3000/110", function( data ){
|
||||
$( "#result" ).html( data );
|
||||
});
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user