Spaces:
Runtime error
Runtime error
buletomato25
commited on
Commit
·
96e3aa5
1
Parent(s):
827df36
pull0323
Browse files- app.py +16 -0
- static/login.js +41 -0
- templates/login.html +156 -0
app.py
CHANGED
|
@@ -192,6 +192,22 @@ def reset():
|
|
| 192 |
users = []
|
| 193 |
return jsonify({"status": "success", "message": "Users reset"}), 200
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
@app.route('/upload_base_audio', methods=['POST'])
|
| 197 |
def upload_base_audio():
|
|
|
|
| 192 |
users = []
|
| 193 |
return jsonify({"status": "success", "message": "Users reset"}), 200
|
| 194 |
|
| 195 |
+
@app.route('/login', methods=['POST', 'GET'])
|
| 196 |
+
def login():
|
| 197 |
+
global users#グローバル変数を編集できるようにする
|
| 198 |
+
try:
|
| 199 |
+
data = request.get_json()
|
| 200 |
+
name = data['name'] # 名前を取得
|
| 201 |
+
if name in users:
|
| 202 |
+
print("名前はリストに存在します。")
|
| 203 |
+
index()
|
| 204 |
+
else:
|
| 205 |
+
print("名前はリストに存在しません。")
|
| 206 |
+
|
| 207 |
+
except Exception as e:
|
| 208 |
+
print("Error in /upload_base_audio:", str(e))
|
| 209 |
+
return jsonify({"error": "サーバーエラー", "details": str(e)}), 500
|
| 210 |
+
|
| 211 |
|
| 212 |
@app.route('/upload_base_audio', methods=['POST'])
|
| 213 |
def upload_base_audio():
|
static/login.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
let mediaRecorder;
|
| 2 |
+
let audioChunks = [];
|
| 3 |
+
let userCount = 0; // 追加されたメンバー数を保持
|
| 4 |
+
let isRecording = false; // 録音中かどうかを判定するフラグ
|
| 5 |
+
let currentRecordingButton = null; // 現在録音中のボタンを保持
|
| 6 |
+
let userNames = [];
|
| 7 |
+
|
| 8 |
+
document.getElementById("login-btn").addEventListener("click", function () {
|
| 9 |
+
const nameInput = document.querySelector('#people-list input[name="name"]');
|
| 10 |
+
const name = nameInput ? nameInput.value.trim() : "";
|
| 11 |
+
|
| 12 |
+
if (!name) {
|
| 13 |
+
alert("名前を入力してください");
|
| 14 |
+
return;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
fetch("/login", {
|
| 18 |
+
method: "POST",
|
| 19 |
+
headers: {
|
| 20 |
+
"Content-Type": "application/json",
|
| 21 |
+
},
|
| 22 |
+
body: JSON.stringify({ name: name }),
|
| 23 |
+
})
|
| 24 |
+
.then((response) => response.json())
|
| 25 |
+
.then((data) => {
|
| 26 |
+
if (data.error) {
|
| 27 |
+
alert("エラー: " + data.error);
|
| 28 |
+
console.error(data.details);
|
| 29 |
+
} else {
|
| 30 |
+
console.log("ログイン成功:", data);
|
| 31 |
+
// ここでUIの更新や次のアクションを追加できます
|
| 32 |
+
}
|
| 33 |
+
})
|
| 34 |
+
.catch((error) => {
|
| 35 |
+
console.error("通信エラー:", error);
|
| 36 |
+
alert("ログイン中にエラーが発生しました");
|
| 37 |
+
});
|
| 38 |
+
});
|
| 39 |
+
function Register() {
|
| 40 |
+
window.location.href = "userregister";
|
| 41 |
+
}
|
templates/login.html
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ja">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<title>ユーザー音声登録</title>
|
| 6 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 7 |
+
<script src="https://use.fontawesome.com/releases/v5.10.0/js/all.js"></script>
|
| 8 |
+
<style>
|
| 9 |
+
@keyframes pulse-scale {
|
| 10 |
+
0%,
|
| 11 |
+
100% {
|
| 12 |
+
transform: scale(1);
|
| 13 |
+
}
|
| 14 |
+
50% {
|
| 15 |
+
transform: scale(1.1);
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
.animate-pulse-scale {
|
| 19 |
+
animation: pulse-scale 1s infinite;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/* Record Button Styles */
|
| 23 |
+
.record-button {
|
| 24 |
+
width: 50px;
|
| 25 |
+
height: 50px;
|
| 26 |
+
background-color: transparent;
|
| 27 |
+
border-radius: 50%;
|
| 28 |
+
border: 2px solid white;
|
| 29 |
+
display: flex;
|
| 30 |
+
justify-content: center;
|
| 31 |
+
align-items: center;
|
| 32 |
+
cursor: pointer;
|
| 33 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
|
| 34 |
+
transition: all 0.3s ease;
|
| 35 |
+
}
|
| 36 |
+
.record-icon {
|
| 37 |
+
width: 35px;
|
| 38 |
+
height: 35px;
|
| 39 |
+
background-color: #d32f2f;
|
| 40 |
+
border-radius: 50%;
|
| 41 |
+
transition: all 0.3s ease;
|
| 42 |
+
}
|
| 43 |
+
.record-button.recording .record-icon {
|
| 44 |
+
background-color: #f44336; /* 録音中は赤色 */
|
| 45 |
+
border-radius: 4px; /* 録音時に赤い部分だけ四角にする */
|
| 46 |
+
}
|
| 47 |
+
.recording .record-icon {
|
| 48 |
+
width: 20px;
|
| 49 |
+
height: 20px;
|
| 50 |
+
border-radius: 50%;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/* Main Container */
|
| 54 |
+
body {
|
| 55 |
+
background: linear-gradient(135deg, #2c3e50, #1f2937);
|
| 56 |
+
display: flex;
|
| 57 |
+
align-items: center;
|
| 58 |
+
justify-content: center;
|
| 59 |
+
min-height: 100vh;
|
| 60 |
+
font-family: "Arial", sans-serif;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/* Main Content Wrapper */
|
| 64 |
+
.main-content {
|
| 65 |
+
border: 5px solid rgba(255, 255, 255, 0.2);
|
| 66 |
+
padding: 2rem;
|
| 67 |
+
border-radius: 1rem;
|
| 68 |
+
width: 90%;
|
| 69 |
+
max-width: 500px;
|
| 70 |
+
background-color: rgba(0, 0, 0, 0.3);
|
| 71 |
+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
|
| 72 |
+
text-align: center;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/* Title */
|
| 76 |
+
.main-title {
|
| 77 |
+
font-size: 2.5rem;
|
| 78 |
+
font-weight: bold;
|
| 79 |
+
margin-bottom: 1.5rem;
|
| 80 |
+
color: #fff;
|
| 81 |
+
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/* Buttons */
|
| 85 |
+
.action-button {
|
| 86 |
+
margin-top: 1rem;
|
| 87 |
+
padding: 0.75rem 1.5rem;
|
| 88 |
+
border-radius: 0.5rem;
|
| 89 |
+
cursor: pointer;
|
| 90 |
+
transition: background-color 0.2s ease;
|
| 91 |
+
width: 100%;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.action-button:hover {
|
| 95 |
+
background-color: rgba(55, 65, 81, 0.7);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.back-button {
|
| 99 |
+
background-color: #607d8b; /* 落ち着いたグレー */
|
| 100 |
+
color: white;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.add-button {
|
| 104 |
+
background-color: #4caf50; /* 落ち着いた緑色 */
|
| 105 |
+
color: white;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/* Disabled State */
|
| 109 |
+
.disabled {
|
| 110 |
+
opacity: 0.5;
|
| 111 |
+
pointer-events: none;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/* Responsive Design */
|
| 115 |
+
@media (max-width: 640px) {
|
| 116 |
+
.main-content {
|
| 117 |
+
padding: 1.5rem;
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
</style>
|
| 121 |
+
</head>
|
| 122 |
+
<body>
|
| 123 |
+
<!-- Main Content Wrapper -->
|
| 124 |
+
<div class="main-content relative">
|
| 125 |
+
<!-- Title -->
|
| 126 |
+
<div class="main-title">ログイン</div>
|
| 127 |
+
|
| 128 |
+
<!-- HTML -->
|
| 129 |
+
<div id="people-list" class="space-y-4">
|
| 130 |
+
<input
|
| 131 |
+
type="text"
|
| 132 |
+
name="name"
|
| 133 |
+
placeholder="名前を入力"
|
| 134 |
+
value="${userName}"
|
| 135 |
+
class="flex-1 px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-gray-700 text-white"
|
| 136 |
+
/>
|
| 137 |
+
</div>
|
| 138 |
+
|
| 139 |
+
<!-- Add Button -->
|
| 140 |
+
<button id="login-btn" class="action-button add-button">
|
| 141 |
+
<i class="fas fa-user-plus"></i> ログイン
|
| 142 |
+
</button>
|
| 143 |
+
|
| 144 |
+
<!-- Back Button -->
|
| 145 |
+
<button
|
| 146 |
+
id="backButton"
|
| 147 |
+
onclick="Register()"
|
| 148 |
+
class="action-button back-button"
|
| 149 |
+
>
|
| 150 |
+
新規録音
|
| 151 |
+
</button>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
<script src="{{ url_for('static', filename='login.js') }}"></script>
|
| 155 |
+
</body>
|
| 156 |
+
</html>
|