Fixes.
This commit is contained in:
parent
0a969776dd
commit
7bf2167dd8
|
@ -3,7 +3,7 @@ import handy_http_starter;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
Http1TransportConfig transportConfig = defaultConfig();
|
Http1TransportConfig transportConfig = defaultConfig();
|
||||||
transportConfig.port = 8080;
|
transportConfig.port = 8110;
|
||||||
HttpTransport transport = new TaskPoolHttp1Transport(new AppHandler(), transportConfig);
|
HttpTransport transport = new TaskPoolHttp1Transport(new AppHandler(), transportConfig);
|
||||||
transport.start();
|
transport.start();
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,11 @@ void getEntries(string partyName, ref ServerHttpResponse response) {
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.path;
|
import std.path;
|
||||||
import std.json;
|
import std.json;
|
||||||
if (!exists("data")) return;
|
|
||||||
const filename = buildPath("data", partyName ~ ".json");
|
const filename = buildPath("data", partyName ~ ".json");
|
||||||
|
if (!exists(filename)) {
|
||||||
|
response.writeBodyString("[]", ContentTypes.APPLICATION_JSON);
|
||||||
|
return;
|
||||||
|
}
|
||||||
JSONValue root = parseJSON(readText(filename));
|
JSONValue root = parseJSON(readText(filename));
|
||||||
response.writeBodyString(root.object["entries"].toJSON(), ContentTypes.APPLICATION_JSON);
|
response.writeBodyString(root.object["entries"].toJSON(), ContentTypes.APPLICATION_JSON);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Party Signup 🎉</title>
|
<title>Party Signup 🎉</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
<style>
|
<style>
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
@ -50,6 +51,7 @@
|
||||||
const nameInput = document.getElementById("name-input")
|
const nameInput = document.getElementById("name-input")
|
||||||
const commentInput = document.getElementById("comment-input")
|
const commentInput = document.getElementById("comment-input")
|
||||||
const registerButton = document.getElementById("register-button")
|
const registerButton = document.getElementById("register-button")
|
||||||
|
const BASE_URL = "https://party-signup.andrewlalis.com/api"
|
||||||
|
|
||||||
registerButton.onclick = addEntry
|
registerButton.onclick = addEntry
|
||||||
nameInput.onchange = validateInput
|
nameInput.onchange = validateInput
|
||||||
|
@ -65,7 +67,7 @@
|
||||||
|
|
||||||
async function loadEntries() {
|
async function loadEntries() {
|
||||||
tableBody.innerHTML = ''
|
tableBody.innerHTML = ''
|
||||||
const response = await fetch("http://localhost:8080?party=" + partyName)
|
const response = await fetch(BASE_URL + "?party=" + partyName)
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.error(await response.text())
|
console.error(await response.text())
|
||||||
} else {
|
} else {
|
||||||
|
@ -90,7 +92,7 @@
|
||||||
comment: comment,
|
comment: comment,
|
||||||
partyName: partyName
|
partyName: partyName
|
||||||
}
|
}
|
||||||
const response = await fetch("http://localhost:8080", {
|
const response = await fetch(BASE_URL, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
})
|
})
|
Loading…
Reference in New Issue