diff --git a/main.py b/main.py index b7cffb69b9489b14e647c952c6fbff0a352eb684..0dddeee152d80f3d863fa68e1706595ab0ba7f4e 100644 --- a/main.py +++ b/main.py @@ -1,39 +1,42 @@ from flask import Flask, request, render_template, redirect import sqlite3 - +app = Flask(__name__) DATABASE = "db.db" ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) -app = Flask(__name__) + @app.route("/Load/CodeBase") def Load(): - Name = "CodeBase"; + Name = "Codebase"; conn = sqlite3.connect(DATABASE) cur = conn.cursor() + print(Name) + # getAddress(Name) cur.execute("SELECT * FROM 'coworking_spaces' WHERE Name =?;", [Name]) data = cur.fetchall() print(data) # cur.execute("SELECT Address FROM coworking_spaces WHERE Name =? ;", [Name]) # Address = cur.fetchall() + # print(Address) # cur.execute("SELECT Main_Photo FROM coworking_spaces WHERE Name =? ;", [Name]) # Main_Photo = cur.fetchall() + # print(Main_Photo) # cur.execute("SELECT Additional_photos FROM coworking_spaces WHERE Name =? ;", [Name]) # Additional_photos = cur.fetchall() + # print(Additional_photos) # cur.execute("SELECT Description FROM coworking_spaces WHERE Name =? ;", [Name]) # Description = cur.fetchall() + # print(Description) # cur.execute("SELECT Website FROM coworking_spaces WHERE Name =? ;", [Name]) # Website = cur.fetchall() + # print(Website) # cur.execute("SELECT Opening_Hours FROM coworking_spaces WHERE Name =? ;", [Name]) # Opening_Hours = cur.fetchall() + # print(Opening_Hours) conn.close() return render_template('Space.html', data = data) - - - - - - + # pageAddress = Address, pageMain_Photo = Main_Photo, pageAdditional_photos = Additional_photos, pageDescription = Description, pageWebsite = Website, pageOpening_Hours = Opening_Hours ) if __name__ == "__main__": app.run(debug=True) diff --git a/static/JS/spaces.js b/static/JS/spaces.js index 1c95d0b3e8c92931ac7a69d412b3bcdf3bfe3f80..9e28dc1d63e067f863308752506a903ad563c2bd 100644 --- a/static/JS/spaces.js +++ b/static/JS/spaces.js @@ -1,13 +1,63 @@ function loadSpaceInfo() { var xhttp = new XMLHttpRequest(); - xhttp.open("PUT", '/Load/CodeBase', true); + xhttp.open('/Load/CodeBase', true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + xhttp.onreadystatechange = getAddress() { + if (this.readyState == 4 && this.status == 200) { + + document.getElementById("AddressText").innerHTML = xhttp.responseText; + console.log(xhttp.responseText); + } + + + xhttp.onreadystatechange = getMain_Photo() { + if (this.readyState == 4 && this.status == 200) { + + document.getElementById("Main_PhotoText").innerHTML = xhttp.responseText; + console.log(xhttp.responseText); + } + + + xhttp.onreadystatechange = getAdditional_photos() { + if (this.readyState == 4 && this.status == 200) { + + document.getElementById("Additional_photosText").innerHTML = xhttp.responseText; + console.log(xhttp.responseText); + } + + + xhttp.onreadystatechange = getWebsite() { + if (this.readyState == 4 && this.status == 200) { + + document.getElementById("WebsiteText").innerHTML = xhttp.responseText; + console.log(xhttp.responseText); + } + + + xhttp.onreadystatechange = getDescription() { + if (this.readyState == 4 && this.status == 200) { + + document.getElementById("DescriptionText").innerHTML = xhttp.responseText; + console.log(xhttp.responseText); + } + + + xhttp.onreadystatechange = getOpening_Hours() { + if (this.readyState == 4 && this.status == 200) { + + document.getElementById("Opening_HoursText").innerHTML = xhttp.responseText; + console.log(xhttp.responseText); + } + + + xhttp.onreadystatechange = function() { if (xhttp.readyState === 4 && xhttp.status === 200) { console.log(xhttp.responseText); // Below is the message to output onto the workspace page, document.getElementById("loadText").innerHTML = xhttp.responseText; + console.log(xhttp.responseText); } else { // console.error(`Status Text: ${xhttp.statusText}.`); // console.error(`Ready State: ${xhttp.readyState}.`); diff --git a/templates/OurSpaces.html b/templates/OurSpaces.html index 8dced386d4b8dd2cffbb3bb8c2ee26ce70b619d0..8da549fbb37b545948a0d7293770715444ea992d 100644 --- a/templates/OurSpaces.html +++ b/templates/OurSpaces.html @@ -1,40 +1,40 @@ - <head> - <link rel="stylesheet" href="framework.css"> +<head> +<link rel="stylesheet" href="static/CSS/framework.css"> </head> <body class="body"> <header> - {% block titleBlock%} - <h1> the working space name</h1> - <img src="header.png"/> - {%endblock%} + <h1>{% block titleBlock%} {%endblock%}</h1> </header> -<div class="Address box"> -{% block addressBlock%} -<h2>Address info</h2> -<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d4957.954181608377!2d-2.999839445369478!3d51.58698324808131!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4871e6cc3bd82553%3A0x684c1227f14b4a15!2sNational%20Software%20Academy%20(Cardiff%20University)!5e0!3m2!1sen!2suk!4v1669722978098!5m2!1sen!2suk" - width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe> -{%endblock%} +<div class="Image box"> +<img src="{% block imageBlock%}{%endblock%}"width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"> </div> <div class="Description box"> - {% block descriptionBlock%} <h2>About us</h2> -<h3>description</h3> - {%endblock%} +<h3>{% block descriptionBlock%} {%endblock%}</h3> </div> -<div class="Image box"> -{% block imageBlock%}<img scr= >{%endblock%} +<div class="Address box"> +<h2>Address info</h2> +{% block addressBlock%} +{%endblock%} </div> <div class="AddImage box"> -{% block addimageBlock%}<img scr=" ">{%endblock%} + <img src="{% block addimageBlock%}{%endblock%}"width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"> </div> <div class="times box"> -<h2>{% block timeBlock%} times {%endblock%}</h2> + <h2>When are we Open?</h2> + <h3>{% block timeBlock%} {%endblock%}</h3> </div> + +<div class="Website box"> + <h2><a href="{% block WebsiteBlock%}{%endblock%}">Get More Info</a><h2> + <h3></h3> +</div> + </body> diff --git a/templates/Space.html b/templates/Space.html index 6714b6aa1dfecb99279c272031f18b4d9419fe32..1d6b0f68300827d8ececa2295253387ad55477c8 100644 --- a/templates/Space.html +++ b/templates/Space.html @@ -1,61 +1,33 @@ {%extends 'OurSpaces.html'%} <form id='myForm' action='/Load/CodeBase>' method ='post'> {% block titleBlock%} - <h1 id="name"></h1><br> - <td>data</td> - <img src= Main_Photo><br> -<script type="text/javascript"> - document.getElementById("name").innerHTML= data; -</script> -<script defer src+"Space.js"></script> -<p id="loadText">temp text</p> -<table border = 1> - <thead> - <td>Name</td> - <td>Address</td> - <td>Main_Photo</td> - <td>Additional_photos</td> - <td>Description</td> - <td>Website</td> - <td>Opening_Hours</td> - </thead> - - {% for row in data %} - - <tr> - <td>{{row[0]}}</td> - <td>{{row[1]}}</td> - <td>{{row[2]}}</td> - <td>{{row[3]}}</td> - <td>{{row[4]}}</td> - <td>{{row[5]}}</td> - <td>{{row[6]}}</td> - </tr> - {% endfor %} -</table> + {%if data%} + {{data[0][0]}} <br> + {%endif%} {%endblock%} {% block addressBlock%} + + {%if data%} + {{data[0][1]}} + {%endif%} + <h2><br></h2> <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d4957.954181608377!2d-2.999839445369478!3d51.58698324808131!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4871e6cc3bd82553%3A0x684c1227f14b4a15!2sNational%20Software%20Academy%20(Cardiff%20University)!5e0!3m2!1sen!2suk!4v1669722978098!5m2!1sen!2suk" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe> {%endblock%} - {% block descriptionBlock%} -<h2>About us</h2> -<h3><input type = "text" name = "Description"><br></h3> - {%endblock%} - {% block imageBlock%} - "<input type = "text" name = "Main_Photos">"<br> - {%endblock%} - {% block addimageBlock%} - "<input type = "text" name = "Additional_photos">"<br> - {%endblock%} + {% block descriptionBlock%}{%if data%}{{data[0][4]}}{%endif%}{%endblock%} + + {% block imageBlock%}{%if data%}{{data[0][2]}}{%endif%}{%endblock%} + + {% block addimageBlock%}{%if data%}{{data[0][3]}}{%endif%}{%endblock%} - {% block timeBlock%} <input type = "text" name = "Opening_Hours"> {%endblock%} + {% block timeBlock%}{%if data%}{{data[0][8]}}{%endif%}{%endblock%} + {% block WebsiteBlock%}{%if data%}{{data[0][5]}}{%endif%}{%endblock%} <span id='txt'></span> <script>