Skip to content
Snippets Groups Projects
Commit fc0751cb authored by Liam Driscoll's avatar Liam Driscoll
Browse files

Adding locations and template route.

parent a6f51012
No related branches found
No related tags found
1 merge request!51Adding locations and template route.
import os
import sqlite3
from flask import Flask, redirect, request, render_template, jsonify
from flask import Flask, redirect, request, render_template, jsonify, url_for, flash, session
app = Flask(__name__)
DATABASE = "project_db.db"
app.secret_key = "hello"
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
......@@ -27,6 +28,16 @@ def returnManageCoworkingSpaces():
if (request.method == 'GET'):
return render_template("Manage_Coworking_Spaces.html")
@app.route("/ListLocations", methods=['GET'])
def returnListLocations():
if (request.method =='GET'):
conn = connect_db()
cur = conn.cursor()
cur.execute("SELECT Name, Main_Photo FROM coworking_spaces")
locationData = cur.fetchall()
conn.close()
return render_template("ListLocations.html", data = locationData)
@app.route("/Load/CodeBase")
def Load():
Name = "Codebase";
......@@ -59,7 +70,6 @@ def Load():
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 )
@app.route("/SearchRecord", methods=['POST', 'GET'])
def searchRecord():
......@@ -177,5 +187,30 @@ def updateRecord():
print(infoMessage)
return (infoMessage)
@app.route("/locations", methods=["POST" , "GET"])
def Locations():
print('Processing location')
if request.method == "POST":
session.permanent = True
locationsName = request.form['name']
locationPic = request.form['image']
conn = sqlite3.connect(DATABASE)
cur = conn.cursor()
cur.execute("SELECT Name, Main_photo FROM coworking_spaces WHERE Name= ?;", [locationsName])
conn.commit()
conn.close()
msg= " Location added successfuly!"
return render_template('locations.html')
if __name__ == "__main__":
app.run(debug=True)
{%extends "base_template.html"%}
{%block headblock%}
<title> Locations </title>
{%endblock%}
{%block headerblock%}
<a id="headerText"
href="ListLocations">
Locations</a>
{%endblock%}
{%block mainblock%}
<br><br>
{%if data%}
{%for x in range(data|length)%}
{{data[x][0]}}
{{data[x][1]}}
<br><br>
{%endfor%}
{%endif%}
{%endblock%}
{%block jsblock%}
{%endblock%}
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