Im trying to link a js file in a HTML file, with the website running on localhost:5000, but it cant seem to locate the js file. Im using Flask as well, below is the HTML, python and js files: HTML:
<!DOCTYPE html>
<html>
<script src="sign_up.js"></script>
<head>
<h1> You're only a few steps away now </h1>
</head>
<body>
<div id="SignUpForm">
<p id="head"></p>
<h2>Enter your details to continue to MyRecipes</h2>
<form action="{{url_for('addUser')}}" method ="post" onsubmit="return validateForm()">
Full Name: <input type="text" name=""="name"><br><br>
Email: <input type="text" name="email"><br><br>
Username (max. 10 characters): <input type="text" name="username"><br><br>
Password (min. 8 characters, at least 1 number and 1 upper-case letter): <input type="text" name="pass"><br><br>
<input type="submit" value="Join MyRecipes">
</form>
</body>
</html>
python:
from flask import Flask, render_template, request
import sqlite3
app = Flask(__name__)
users = sqlite3.connect('users.db')
print("Opened database successfully")
@app.route("/", methods = ['GET', 'POST'])
def home():
return render_template("index.html")
@app.route("/sign_up")
def signup():
return render_template("signup.html")
@app.route('/addUser', methods=['POST'])
def addUser():
passw = request.form['pass']
print(passw)
# your code
# return a response
return render_template("signup_success.html")
if __name__ == '__main__':
app.run(debug=True)
js:
function validateForm(){
var name = document.getElementById('name');
if (name.value.length == 0){
document.getElementById('head').innerText = "* All fields necessary *";
name.focus();
return false;
}
return true
}
Ive tried a lot of different other paths to src"", but nothing seems to work, can anyone see the issue here?
Edit: Forgot to say, the sign_up.js file is in the templates folder, along with the other html files.