Commit 5ec8444b authored by Magnus Holm Brunbjerg's avatar Magnus Holm Brunbjerg
Browse files

Experiment start

parent 85cfb4f8
......@@ -49,9 +49,39 @@ app.use((req, res, next) => {
// Frontpage
app.get('/', (req, res, next) => {
res.render('index', {
meta: {
title: 'Forside'
fetch(`http://${apiIp}:${apiPort}${apiPath}/experiments/running`, {
method: 'GET',
mode: 'cors',
headers: {
'Accept': 'application/json'
}
}).then((response) => {
return response.json()
}).then((data) => {
if (data) {
res.render('index', {
meta: {
title: 'Forside'
},
running: data
})
} else {
fetch(`http://${apiIp}:${apiPort}${apiPath}/users`, {
method: 'GET',
mode: 'cors',
headers: {
'Accept': 'application/json'
}
}).then((response) => {
return response.json()
}).then((data) => {
res.render('index', {
meta: {
title: 'Forside'
},
users: data
})
})
}
})
})
......
<h1>Forside</h1>
<p>Forside content</p>
\ No newline at end of file
<form method="POST" action="/">
<div>
<label for="user">Lærer:</label>
{{#if running}}
<input type="text" name="user" id="user" disabled="true" value="{{running.user_name}}">
{{else}}
<input type="text" name="user" id="user" list="users">
<datalist id="users">
{{#each users}}
<option value="{{this.user_name}}" id="{{this.id}}"></option>
{{/each}}
</datalist>
{{/if}}
</div>
<div>
<label for="name">Navn:</label>
<input type="text" name="name" id="name">
</div>
<div>
<button type="submit">Submit</button>
</div>
</form>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment