Я пытаюсь разрешить пользователям отправлять свои расчеты гематрии в текстовый файл, чтобы я мог проверить их вручную перед отправкой в базу данных;поэтому я поместил простую форму внутри модального окна с вводом type = "submit", но я продолжаю получать ошибку 400 неверных запросов и не могу понять, почему это не работает.
Я использую серверную сторону Python3.6 с флягой и НЕ использую загрузчик с HTML.
Серверная сторона:
if request.form["action"] == "Send":
Name = request.form["name"]
Email = request.form["mail"]
GematriaNum = request.form["gematria"]
Source = request.form["source"]
Calc = request.form["calc"]
LIT = request.form["transliteration"]
LANGY = request.form["translation"]
NEWSL = request.form["newsletter"]
BODYOF = Name + Email + GematriaNum + Source + Calc + LIT + LANGY + NEWSL
with open("submiss.txt", "w") as submiss:
submiss.write(BODYOF)
return render_template("index.html")
return redirect(url_for('index'))
Код веб-страницы:
<!-- ...it's part of a nav bar. -->
<!-- Trigger/Open The Modal -->
<li><a id="myBtn">Submit your Calculations to the Database!</a></li>
</ul>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<form action="." method="POST"><span>
Name:<br>
<textarea style="resize:none" name="name" cols="25" rows="1" maxlength="25"></textarea><br>
E-mail:<br>
<textarea style="resize:none" name="mail" cols="25" rows="1" maxlength="25"></textarea><br>
Gematria Number:<br>
<textarea style="resize:none" name="gematria" cols="25" rows="1" maxlength="25"></textarea><br>
Source Text [i.e. Exodus 2:12]:<br>
<textarea style="resize:none" name="source" cols="25" rows="1" maxlength="25"></textarea><br>
Calculation in Hebrew, Greek or English:<br>
<textarea style="resize:none" name="calc" cols="50" rows="1" maxlength="100"></textarea><br>
Transliteration (if applicable):<br>
<textarea style="resize:none" name="transliteration" cols="50" rows="1" maxlength="100"></textarea><br>
Meaning and Usage:<br>
<textarea style="resize:none" name="translation" cols="50" rows="1" maxlength="100"></textarea><br>
<br>
<input type="checkbox" checked="checked" name="newsletter" style="margin-bottom:15px"> Sign up for our newsletter?<br>
<input type="submit" value="Send"></span>
<input type="reset" value="Reset">
</form>
<br>
Thanks!
</div>
</div>
<script>
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
Вы можете увидеть сайт в режиме реального времени здесь .
Я надеюсь, что вы можете помочь.