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