デプロイ方法をユーザーに任せる
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>太鼓ウェブあっぷろーだー</title>
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
<script src="./upload.js"></script>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="upload.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>太鼓ウェブあっぷろーだー</h1>
|
||||
|
||||
@@ -15,9 +15,9 @@ body * {
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 3rem;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
body > *:not(:last-child) {
|
||||
margin-bottom: 3rem;
|
||||
body > :not(:last-child) {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
function uploadFiles() {
|
||||
const form = document.getElementById('upload-form');
|
||||
const form = document.querySelector("#upload-form");
|
||||
const formData = new FormData(form);
|
||||
|
||||
fetch('/upload', {
|
||||
method: 'POST',
|
||||
fetch("/upload", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
} else {
|
||||
throw new Error(res.url + " で " + res.status.toString() + " が発生しました。");
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
.then((data) => {
|
||||
if (data.success) {
|
||||
alert("おめでとう!ファイルの投稿に成功しました!");
|
||||
} else {
|
||||
throw new Error(data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('エラー:', error);
|
||||
document.getElementById("error-view").textContent = error;
|
||||
.catch((error) => {
|
||||
console.error("エラー:", error);
|
||||
document.querySelector("#error-view").textContent = error;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user