2020-12-19 14:54:35 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Mock Car API Admin</title>
|
2020-12-21 09:40:49 +01:00
|
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='admin.css')}}" type="text/css">
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
|
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@1,100&display=swap" rel="stylesheet">
|
2020-12-19 14:54:35 +01:00
|
|
|
</head>
|
|
|
|
<body>
|
2020-12-21 09:40:49 +01:00
|
|
|
<header>
|
|
|
|
<h1>Mock Data API</h1>
|
|
|
|
</header>
|
2020-12-19 14:54:35 +01:00
|
|
|
<div class="change">
|
2020-12-21 09:40:49 +01:00
|
|
|
<input class="input-box" type="text" name="key" id="key" placeholder="Key">
|
|
|
|
<input class="input-box" type="text" name="value" id="value" placeholder="Valid JSON values">
|
|
|
|
</div>
|
|
|
|
<div class='button-dec'>
|
2020-12-19 14:54:35 +01:00
|
|
|
<button type="submit" id="#submit" onclick="updateData()">Change / Add</button>
|
|
|
|
</div>
|
2020-12-21 09:40:49 +01:00
|
|
|
<div class="table-dec">
|
|
|
|
<table class="content-table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<td>Key</td>
|
|
|
|
<td>Value</td>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
{% for key, value in data.items() %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ key }}</td>
|
|
|
|
<td>{{ value }}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2020-12-19 14:54:35 +01:00
|
|
|
<script charset="utf-8">
|
|
|
|
function updateData() {
|
|
|
|
const key = document.querySelector("#key").value;
|
|
|
|
const value = document.querySelector("#value").value;
|
|
|
|
fetch(`/data/${key}`, {
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify({value: JSON.parse(value)})
|
|
|
|
}).then(() => window.location.reload(true));
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|