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

Search button functionality.

parent 69ab9bfc
No related branches found
No related tags found
1 merge request!36Search button functionality.
......@@ -7,6 +7,27 @@ DATABASE = "project_db.db"
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
@app.route("/SearchRecord", methods=['POST'])
def searchRecord():
print('Processing search.')
infoMessage = ('Record not found.')
if request.method =='POST':
recordName = request.form.get('recordName', default="Error")
conn = sqlite3.connect(DATABASE)
cur = conn.cursor()
cur.execute("SELECT * FROM coworking_spaces WHERE Name=?;", [recordName])
recordData = cur.fetchall()
conn.close()
infoMessage = (f'{recordData} Record search.')
return str(recordData)
print(infoMessage)
return (infoMessage)
# Adds a record to the CSV file.
@app.route("/AddRecord", methods=['POST'])
def addRecord():
......
......@@ -42,18 +42,9 @@ function searchRecord(e) {
// Assigning form element values to variables.
var recordName = document.getElementById("recordName").value;
var recordAddress = document.getElementById("recordAddress").value;
var recordMainPhotos = document.getElementById("recordMainPhotos").value;
var recordAdditionalPhotos = document.getElementById("recordAdditionalPhotos").value;
var recordDescription = document.getElementById("recordDescription").value;
var recordWebsite = document.getElementById("recordWebsite").value;
var recordEmail = document.getElementById("recordEmail").value;
var recordPhoneNumber = document.getElementById("recordPhoneNumber").value;
var recordOpeningHours = document.getElementById("recordOpeningHours").value;
var recordCheckinInstructions = document.getElementById("recordCheckinInstructions").value;
// Creating a form data-type to transfer multiple parameters to the server.
var params = 'recordName='+recordName+'&recordAddress='+recordAddress+'&recordMainPhotos='+recordMainPhotos+'&recordAdditionalPhotos='+recordAdditionalPhotos+'&recordDescription='+recordDescription+'&recordWebsite='+recordWebsite+'&recordEmail='+recordEmail+'&recordPhoneNumber='+recordPhoneNumber+'&recordOpeningHours='+recordOpeningHours+'&recordCheckinInstructions='+recordCheckinInstructions;
var params = 'recordName='+recordName;
var xhttp = new XMLHttpRequest();
xhttp.open("POST", '/SearchRecord', true);
......
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