Skip to content
Snippets Groups Projects
Commit 8e22eecb authored by Beaumont Mogridge's avatar Beaumont Mogridge :gorilla:
Browse files

updated and working

parent aa0d4cc1
No related branches found
No related tags found
1 merge request!47Update static/testSearch.html, templates/OurSpaces.html, templates/Space.html,...
from flask import Flask, request, render_template, redirect from flask import Flask, request, render_template, redirect
import sqlite3 import sqlite3
app = Flask(__name__)
DATABASE = "db.db" DATABASE = "db.db"
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
app = Flask(__name__)
@app.route("/Load/CodeBase") @app.route("/Load/CodeBase")
def Load(): def Load():
Name = "CodeBase"; Name = "Codebase";
conn = sqlite3.connect(DATABASE) conn = sqlite3.connect(DATABASE)
cur = conn.cursor() cur = conn.cursor()
print(Name)
# getAddress(Name)
cur.execute("SELECT * FROM 'coworking_spaces' WHERE Name =?;", [Name]) cur.execute("SELECT * FROM 'coworking_spaces' WHERE Name =?;", [Name])
data = cur.fetchall() data = cur.fetchall()
print(data) print(data)
# cur.execute("SELECT Address FROM coworking_spaces WHERE Name =? ;", [Name]) # cur.execute("SELECT Address FROM coworking_spaces WHERE Name =? ;", [Name])
# Address = cur.fetchall() # Address = cur.fetchall()
# print(Address)
# cur.execute("SELECT Main_Photo FROM coworking_spaces WHERE Name =? ;", [Name]) # cur.execute("SELECT Main_Photo FROM coworking_spaces WHERE Name =? ;", [Name])
# Main_Photo = cur.fetchall() # Main_Photo = cur.fetchall()
# print(Main_Photo)
# cur.execute("SELECT Additional_photos FROM coworking_spaces WHERE Name =? ;", [Name]) # cur.execute("SELECT Additional_photos FROM coworking_spaces WHERE Name =? ;", [Name])
# Additional_photos = cur.fetchall() # Additional_photos = cur.fetchall()
# print(Additional_photos)
# cur.execute("SELECT Description FROM coworking_spaces WHERE Name =? ;", [Name]) # cur.execute("SELECT Description FROM coworking_spaces WHERE Name =? ;", [Name])
# Description = cur.fetchall() # Description = cur.fetchall()
# print(Description)
# cur.execute("SELECT Website FROM coworking_spaces WHERE Name =? ;", [Name]) # cur.execute("SELECT Website FROM coworking_spaces WHERE Name =? ;", [Name])
# Website = cur.fetchall() # Website = cur.fetchall()
# print(Website)
# cur.execute("SELECT Opening_Hours FROM coworking_spaces WHERE Name =? ;", [Name]) # cur.execute("SELECT Opening_Hours FROM coworking_spaces WHERE Name =? ;", [Name])
# Opening_Hours = cur.fetchall() # Opening_Hours = cur.fetchall()
# print(Opening_Hours)
conn.close() conn.close()
return render_template('Space.html', data = data) 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__": if __name__ == "__main__":
app.run(debug=True) app.run(debug=True)
function loadSpaceInfo() { function loadSpaceInfo() {
var xhttp = new XMLHttpRequest(); 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.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() { xhttp.onreadystatechange = function() {
if (xhttp.readyState === 4 && xhttp.status === 200) { if (xhttp.readyState === 4 && xhttp.status === 200) {
console.log(xhttp.responseText); console.log(xhttp.responseText);
// Below is the message to output onto the workspace page, // Below is the message to output onto the workspace page,
document.getElementById("loadText").innerHTML = xhttp.responseText; document.getElementById("loadText").innerHTML = xhttp.responseText;
console.log(xhttp.responseText);
} else { } else {
// console.error(`Status Text: ${xhttp.statusText}.`); // console.error(`Status Text: ${xhttp.statusText}.`);
// console.error(`Ready State: ${xhttp.readyState}.`); // console.error(`Ready State: ${xhttp.readyState}.`);
......
<head> <head>
<link rel="stylesheet" href="framework.css"> <link rel="stylesheet" href="static/CSS/framework.css">
</head> </head>
<body class="body"> <body class="body">
<header> <header>
{% block titleBlock%} <h1>{% block titleBlock%} {%endblock%}</h1>
<h1> the working space name</h1>
<img src="header.png"/>
{%endblock%}
</header> </header>
<div class="Address box"> <div class="Image box">
{% block addressBlock%} <img src="{% block imageBlock%}{%endblock%}"width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade">
<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> </div>
<div class="Description box"> <div class="Description box">
{% block descriptionBlock%}
<h2>About us</h2> <h2>About us</h2>
<h3>description</h3> <h3>{% block descriptionBlock%} {%endblock%}</h3>
{%endblock%}
</div> </div>
<div class="Image box"> <div class="Address box">
{% block imageBlock%}<img scr= >{%endblock%} <h2>Address info</h2>
{% block addressBlock%}
{%endblock%}
</div> </div>
<div class="AddImage box"> <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>
<div class="times box"> <div class="times box">
<h2>{% block timeBlock%} times {%endblock%}</h2> <h2>When are we Open?</h2>
<h3>{% block timeBlock%} {%endblock%}</h3>
</div> </div>
<div class="Website box">
<h2><a href="{% block WebsiteBlock%}{%endblock%}">Get More Info</a><h2>
<h3></h3>
</div>
</body> </body>
{%extends 'OurSpaces.html'%} {%extends 'OurSpaces.html'%}
<form id='myForm' action='/Load/CodeBase>' method ='post'> <form id='myForm' action='/Load/CodeBase>' method ='post'>
{% block titleBlock%} {% block titleBlock%}
<h1 id="name"></h1><br> {%if data%}
<td>data</td> {{data[0][0]}} <br>
<img src= Main_Photo><br> {%endif%}
<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>
{%endblock%} {%endblock%}
{% block addressBlock%} {% block addressBlock%}
{%if data%}
{{data[0][1]}}
{%endif%}
<h2><br></h2> <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" <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> width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
{%endblock%} {%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%} {% block descriptionBlock%}{%if data%}{{data[0][4]}}{%endif%}{%endblock%}
"<input type = "text" name = "Additional_photos">"<br>
{%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> <span id='txt'></span>
<script> <script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment