diff --git a/project_server.py b/project_server.py index 5e98f5d6b9fcbb3df4e3f062695c061633add707..cf33dbd9506369ebde226b064d99971357b1df12 100644 --- a/project_server.py +++ b/project_server.py @@ -17,7 +17,19 @@ def connect_db(db_file=DATABASE): print("Error connecting to database.") return conn +<<<<<<< HEAD @app.route('/SearchRecord', methods=['POST']) +======= +@app.route("/", methods=['GET']) +def returnIndex(): + return render_template("test.html") + +@app.route("/Manage_Coworking_Spaces", methods=['GET']) +def returnManageCoworkingSpaces(): + return render_template("Manage_Coworking_Spaces.html") + +@app.route("/SearchRecord", methods=['POST']) +>>>>>>> 447d1e30bd664c46c1ad4a89ed35119391ab95a6 def searchRecord(): if (request.method =='POST'): diff --git a/static/CSS/loginstyle.css b/static/CSS/loginstyle.css new file mode 100644 index 0000000000000000000000000000000000000000..2c44a02a44c292502c7c4862d8e8b78d86024f40 --- /dev/null +++ b/static/CSS/loginstyle.css @@ -0,0 +1,29 @@ +header{ + background-color: black; + display: block; + color: black; + margin-left: auto; + margin-right: inherit; + width: 100%; + height: 75%; +} + +.card{ + margin: 0 auto; + float: none; + margin-bottom: 10px; +} + +#logo{ + width: 10%; +} + +body{ + font-family: 'Sora', sans-serif; + background-color: #212529; + color: white; +<<<<<<< HEAD +} +======= +} +>>>>>>> 9c7255d510762a8f16afeba2657cad4a0f8b8239 diff --git a/static/JS/Manage_Coworking_Spaces.js b/static/JS/Manage_Coworking_Spaces.js index c3efb0f50541ce04eecd8d3f6dde8f3fc20fd81b..c20755b76708e03d8d46a91898f0b26f2b98ca6a 100644 --- a/static/JS/Manage_Coworking_Spaces.js +++ b/static/JS/Manage_Coworking_Spaces.js @@ -145,7 +145,7 @@ function deleteRecord(e) { // Creating a form data-type to transfer multiple parameters to the server. var params = 'recordName='+recordName; - + var xhttp = new XMLHttpRequest(); xhttp.open("POST", '/DeleteRecord', true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); diff --git a/static/Manage_Coworking_Spaces.html b/static/Manage_Coworking_Spaces.html deleted file mode 100644 index 26908ef8108f7b8ae8876a4f7d7e9018dadee7bc..0000000000000000000000000000000000000000 --- a/static/Manage_Coworking_Spaces.html +++ /dev/null @@ -1,94 +0,0 @@ -<!DOCTYPE html> -<html lang="EN" dir="ltr"> - <head> - <meta charSet="UTF-8"> - <title> Manage Coworking Spaces </title> - <link rel="stylesheet" href="CSS/Manage_Coworking_Spaces.css"> - - </head> - <body onLoad="pageLoad()"> - - <header id="pageHeader" class="pageHeader"> - <div id="headerDiv"> - <a href="Manage_Coworking_Spaces.html"> - <img id="headerImg" class="headerImg" - src="Media/Tramshed-Logo-Main-Black.png"></img></a> - <a id="headerText" class="headerText" - href="Manage_Coworking_Spaces.html"> - Manage Coworking Spaces</a> - </div> - <nav id="headerNav" class="navBar"> - <ul class="Left"> - <li><a href="Manage_Coworking_Spaces.html"> - <img id="navImg" class="navImg" - src="Media/Tramshed-Logo-Main-White.png"></img></a></li> - <li><a href="Manage_Coworking_Spaces.html">Home</a></li> - <li><a href="Manage_Coworking_Spaces.html">Locations</a></li> - </ul> - <ul class="Right"> - <li><a href="Manage_Coworking_Spaces.html">Manage</a></li> - <li><a href="Manage_Coworking_Spaces.html">Login</a></li> - <li><div class="navHamburger"> - <span></span> - <span></span> - <span></span> - </div></li> - </ul> - </nav> - </header> - - <main id="pageMain"> - <form id="recordForm" title="Record Form"> - <label>Name: <input id="recordName" class="formTextInput" - name="record_name" type="text"></label><br> - <label>Address: <input id="recordAddress" class="formTextInput" - name="record_address" type="text"></label><br> - <label>Main Photograph: <input id="recordMainPhotos" class="formTextInput" - name="record_MP" type="text"></label><br> - <label>Additional Photographs: <input id="recordAdditionalPhotos" class="formTextInput" - name="record_AP" type="text"></label><br> - <label>Description: <input id="recordDescription" class="formTextInput" - name="record_description" type="text"></label><br> - <label>Website: <input id="recordWebsite" class="formTextInput" - name="record_website" type="text"></label><br> - <label>Email: <input id="recordEmail" class="formTextInput" - name="record_email" type="text"></label><br> - <label>Phone Number: <input id="recordPhoneNumber" class="formTextInput" - name="record_PN" type="text"></label><br> - <label>Opening Hours: <input id="recordOpeningHours" class="formTextInput" - name="record_OH" type="text"></label><br> - <label>Checkin Instructions: <input id="recordCheckinInstructions" class="formTextInput" - name="record_CI" type="text"></label> - - <br><br> - <button id="searchButton" type="submit">Search</button> - <button id="addButton" type="submit">Add</button> - <button id="editButton" type="submit">Edit</button> - <button id="deleteButton" type="submit">Delete</button> - </form> - <br> - <span id="DEBUGserverMessage"> </span> - - <br><br><br><br><br><br><br><br><br><br><br><br> - <br><br><br><br><br><br><br><br><br><br><br><br> - <br><br><br><br><br><br><br><br><br><br><br><br> - <br><br><br><br><br><br><br><br><br><br><br><br> - </main> - - <footer id="pageFooter"> - <nav id="footerNav" class="navBar"> - <ul class="Center"> - <li><a href="Manage_Coworking_Spaces.html">Left</a></li> - </ul> - <ul class="Center"> - <li><a href="Manage_Coworking_Spaces.html">Center</a></li> - </ul> - <ul class="Center"> - <li><a href="Manage_Coworking_Spaces.html">Right</a></li> - </ul> - </nav> - </footer> - - <script src="JS/Manage_Coworking_Spaces.js"></script> - </body> -</html> diff --git a/static/Media/logo.png b/static/Media/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f385aaf178033943a2dd7f9cde33a5cf5f230515 Binary files /dev/null and b/static/Media/logo.png differ diff --git a/static/landingpage.html b/static/landingpage.html index b56e8fd9532a49e78e2bf27015a65014f5bd3d18..fca729848a41a620680e438f5ae7728876e074c1 100644 --- a/static/landingpage.html +++ b/static/landingpage.html @@ -12,7 +12,7 @@ <a class="nav-link" href="locations.html">Coworking locations</a> </li> <li class="nav-item"> - <a class="nav-link" href="Manage_Coworking_Spaces.html">Manage locations</a> + <a class="nav-link" href="/Manage_Coworking_Spaces">Manage locations</a> </li> </ul> </div> @@ -31,7 +31,7 @@ <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Sora:wght@800&display=swap" rel="stylesheet"> - <link rel="stylesheet" href="landingstyle.css"> + <link rel="stylesheet" href="CSS/landingstyle.css"> <title>Tramshed Tech</title> <img id="tramshed" src="Media/tramshed.jpg"> <div class="bg-dark p-3"> diff --git a/static/login.html b/static/login.html new file mode 100644 index 0000000000000000000000000000000000000000..5bbe1b72a5529fc7b8b0ff4c1c3fa16cd0b44f59 --- /dev/null +++ b/static/login.html @@ -0,0 +1,75 @@ +<!DOCTYPE html> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> +</head> +<header class="masthead bg-dark text-white text-center"> + <div class="container-fluid"> + <img id="logo" src="Media/logo.png"/> + <h1 id="header">Tramshed Tech</h1> + </div> + </header> +<body> + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"> + <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" ></script> + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js" integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT" crossorigin="anonymous"></script> + <link rel="preconnect" href="https://fonts.googleapis.com"> + <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> + <link href="https://fonts.googleapis.com/css2?family=Sora:wght@800&display=swap" rel="stylesheet"> + <link rel="stylesheet" href="CSS/loginstyle.css"> + <title>Login</title> + <div id="card" class="card text-dark w-25 text-center"> + <div class="card-body text-center"> + + + <form> + <!-- Email input --> + <div class="form-outline mb-4"> +<<<<<<< HEAD + <input type="email" id="recordEmail" class="form-control" /> +======= + <input type="email" id="form2Example1" class="form-control" /> +>>>>>>> 9c7255d510762a8f16afeba2657cad4a0f8b8239 + <label class="form-label" for="form2Example1">Email address</label> + </div> + + <!-- Password input --> + <div class="form-outline mb-4"> +<<<<<<< HEAD + <input type="password" id="recordPassword" class="form-control" /> +======= + <input type="password" id="form2Example2" class="form-control" /> +>>>>>>> 9c7255d510762a8f16afeba2657cad4a0f8b8239 + <label class="form-label" for="form2Example2">Password</label> + </div> + + <!-- 2 column grid layout for inline styling --> + <div class="row mb-4"> + <div class="col d-flex justify-content-center"> + <!-- Checkbox --> + <div class="form-check"> + <input class="form-check-input" type="checkbox" value="" id="form2Example31" checked /> + <label class="form-check-label" for="form2Example31"> Remember me </label> + </div> + </div> + + <div class="col"> + <!-- Simple link --> + <a href="#!">Forgot password?</a> + </div> + + <!-- Submit button --> + <button onclick="window.location.href='landingpage.html';" type="button" class="btn btn-light"> + <span class="spinner-grow spinner-grow-sm"></span> + Sign in + </button> + <!-- Register buttons --> + <div class="text-center"> + <p>Not a member? <a href="#!">Register</a></p> + </form> + </body> +<<<<<<< HEAD +</html> +======= +</html> +>>>>>>> 9c7255d510762a8f16afeba2657cad4a0f8b8239 diff --git a/templates/Manage_Coworking_Spaces.html b/templates/Manage_Coworking_Spaces.html new file mode 100644 index 0000000000000000000000000000000000000000..4daddcc1d7cbb43e10a747f90edd331c74e35084 --- /dev/null +++ b/templates/Manage_Coworking_Spaces.html @@ -0,0 +1,92 @@ +{%extends "base_template.html"%} + +{%block headblock%} + <title> Manage Coworking Spaces </title> + <link rel="stylesheet" href="/static/CSS/Manage_Coworking_Spaces.css"> +{%endblock%} + +{%block onLoadblock%} + pageLoad() +{%endblock%} + +{%block headerblock%} + <div id="headerDiv"> + <a href="Manage_Coworking_Spaces.html"> + <img id="headerImg" class="headerImg" + src="/static/Media/Tramshed-Logo-Main-Black.png"></img></a> + <a id="headerText" class="headerText" + href="Manage_Coworking_Spaces"> + Manage Coworking Spaces</a> + </div> + <nav id="headerNav" class="navBar"> + <ul class="Left"> + <li><a href="Manage_Coworking_Spaces">Home</a></li> + <li><a href="Locations">Locations</a></li> + </ul> + <ul class="Right"> + <li><a href="Manage_Coworking_Spaces">Manage</a></li> + <li><a href="Manage_Coworking_Spaces">Login</a></li> + <li><div class="navHamburger"> + <span></span> + <span></span> + <span></span> + </div></li> + </ul> + </nav> +{%endblock%} + +{%block mainblock%} + <form id="recordForm" title="Record Form"> + <label>Name: <input id="recordName" class="formTextInput" + name="record_name" type="text"></label><br> + <label>Address: <input id="recordAddress" class="formTextInput" + name="record_address" type="text"></label><br> + <label>Main Photograph: <input id="recordMainPhotos" class="formTextInput" + name="record_MP" type="text"></label><br> + <label>Additional Photographs: <input id="recordAdditionalPhotos" class="formTextInput" + name="record_AP" type="text"></label><br> + <label>Description: <input id="recordDescription" class="formTextInput" + name="record_description" type="text"></label><br> + <label>Website: <input id="recordWebsite" class="formTextInput" + name="record_website" type="text"></label><br> + <label>Email: <input id="recordEmail" class="formTextInput" + name="record_email" type="text"></label><br> + <label>Phone Number: <input id="recordPhoneNumber" class="formTextInput" + name="record_PN" type="text"></label><br> + <label>Opening Hours: <input id="recordOpeningHours" class="formTextInput" + name="record_OH" type="text"></label><br> + <label>Checkin Instructions: <input id="recordCheckinInstructions" class="formTextInput" + name="record_CI" type="text"></label> + + <br><br> + <button id="searchButton" type="submit">Search</button> + <button id="addButton" type="submit">Add</button> + <button id="editButton" type="submit">Edit</button> + <button id="deleteButton" type="submit">Delete</button> + </form> + <br> + <span id="DEBUGserverMessage"> </span> + + <br><br><br><br><br><br><br><br><br><br><br><br> + <br><br><br><br><br><br><br><br><br><br><br><br> + <br><br><br><br><br><br><br><br><br><br><br><br> + <br><br><br><br><br><br><br><br><br><br><br><br> +{%endblock%} + +{%block footerblock%} + <nav id="footerNav" class="navBar"> + <ul class="Center"> + <li><a href="Manage_Coworking_Spaces.html">Left</a></li> + </ul> + <ul class="Center"> + <li><a href="Manage_Coworking_Spaces.html">Center</a></li> + </ul> + <ul class="Center"> + <li><a href="Manage_Coworking_Spaces.html">Right</a></li> + </ul> + </nav> +{%endblock%} + +{%block jsblock%} + /static/JS/Manage_Coworking_Spaces.js +{%endblock%} diff --git a/templates/base_template.html b/templates/base_template.html new file mode 100644 index 0000000000000000000000000000000000000000..6460c1ffceb45aa080041be4dc7c93f60104bbce --- /dev/null +++ b/templates/base_template.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="EN" dir="ltr"> + <head> + <meta charSet="UTF-8"> + {%block headblock%} + {%endblock%} + </head> + <body onLoad="{%block onLoadblock%}{%endblock%}"> + + <header id="pageHeader" class="pageHeader"> + {%block headerblock%} + {%endblock%} + </header> + + <main id="pageMain"> + {%block mainblock%} + {%endblock%} + </main> + + <footer id="pageFooter"> + {%block footerblock%} + {%endblock%} + </footer> + + <script src="{%block jsblock%}{%endblock%}"></script> + </body> +</html> diff --git a/templates/test.html b/templates/test.html new file mode 100644 index 0000000000000000000000000000000000000000..1a4bf463bb740559d292fedbe9529176cd2c941e --- /dev/null +++ b/templates/test.html @@ -0,0 +1,4 @@ +{%extends "base_template.html"%} +{%block mainblock%} + test +{%endblock%} diff --git a/testloginserver.py b/testloginserver.py new file mode 100644 index 0000000000000000000000000000000000000000..a28f96dad8ccf4b267f013c3699da65f0ade7f50 --- /dev/null +++ b/testloginserver.py @@ -0,0 +1,46 @@ +import os +import sqlite3 +from flask import Flask, redirect, request, render_template, jsonify + +app = Flask(__name__) +DATABASE = "login.db" + +ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) + +@app.route("/SearchRecord", methods=['POST']) +def searchRecord(): + + if request.method =='POST': + try: + recordEmail = request.form.get('recordEmail', default="Error") + conn = sqlite3.connect(DATABASE) + cur = conn.cursor() + cur.execute("SELECT * FROM login WHERE Email=?;", [recordEmail]) + recordData = cur.fetchall() + except: + print(f"Error: {recordData}") + conn.close() + finally: + conn.close() + print(f"{str(recordData)} Record found.") + return str(recordData) + +@app.route("/AddRecord", methods=['POST']) +def addRecord(): + if (request.method == 'POST'): + recordEmail = request.form['recordEmail'] + recordPassword = request.form['recordPassword'] + conn = sqlite3.connect(DATABASE) + cur = conn.cursor() + cur.execute("INSERT INTO login ('Email', 'Password')\ + VALUES (?,?)", (recordEmail, recordPassword)) + conn.commit() + conn.close() + + infoMessage = (f'{recordData} Record added.') + + print(infoMessage) + return (infoMessage) + +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file