For some inexplicable reason, whenever I add <form></form>
around the three lines above the blockquote, the text inside the blockquote stops being replaced with the text returned from the flask server. I don't have any problem that needs to be solved, as I can easily work around this. I am just curious as to why this issue exists in the first place.
HTML:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="{{ url_for('static', filename='CSSsheets/SBPstyle.css') }}" />
<title></title>
</head>
<body>
<input id="expertiseReq" placeholder="leave blank for any skill level" />
<input id="locationReq" placeholder="leave blank for any location" />
<button id="gatherNames">Click to Get List of Player Names</button>
<blockquote id="playerNamesGoHere" class="properly_sized_blockquote">No Player Names Loaded</blockquote>
<script src="{{ url_for('static', filename='JSscripts/SBPscript.js') }}"></script>
</body>
</html>
CSS:
.properly_sized_blockquote {
border: solid;
border-block-width: 20px;
height: 600px;
width: 150px;
}
JavaScript:
const gatherPlayersButton = document.getElementById('gatherNames');
const areaForPlayerNames = document.getElementById('playerNamesGoHere')
const summon_players = () => {
let eR
let lR
if (document.getElementById('expertiseReq').value == "") {
eR = "None";
} else {
eR = document.getElementById('expertiseReq').value
};
if (document.getElementById('locationReq').value == "") {
lR = "None";
} else {
lR = document.getElementById('locationReq').value
};
let tagsString = eR + "," + lR;
fetch(`/battle?tags=${tagsString}`, { method: "GET" }).then((response) => response.text()).then((text) => {
areaForPlayerNames.innerText = text;
});
};
gatherPlayersButton.addEventListener("click", () => summon_players());
Flask Server:
from flask import Flask, render_template, request
from static.SNEKfiles import SpaceShipGame
import json
game_app = Flask(__name__)
@game_app.route('/')
@game_app.route('/home')
def home():
return render_template("HTMLPage1.html")
@game_app.route('/battle', methods=['GET', 'POST'])
def battle():
if request.method == 'GET':
gathering_player_requirements = request.args.get('tags')
if gathering_player_requirements != None:
print(gathering_player_requirements)
skill_requirement = gathering_player_requirements.split(",")[0]
location_requirement = gathering_player_requirements.split(",")[1]
gathering_player = SpaceShipGame.Player()
gathered_player_names = gathering_player.obtainAllPlayerNames(skill_requirement, location_requirement)
return gathered_player_names
else:
return render_template("SingleBattlePage.html")