the id of the document needs to be in the url as an optional parameter.
- e.g.its currenly https://..../view-document
- and i need it to be https://..../view-document/______
the id is whatever document the user clicks on in the neo4j database which has to be put on the end of the url
the sections of code to alter is routes.py
@app.route('/view-document', methods=['GET', 'POST'])
def view_document():
document_link = active_document_link
document_filepath = os.path.join('../static/sample_documents', document_link)
document = get_document_from_document_link(document_link)
user_name = get_active_user_name()**
index.js
function openDocument(documentFormat, documentLink) {
fetch("/open-document", {
method: "POST",
body: JSON.stringify({ documentFormat: documentFormat, documentLink: documentLink })
}).then((_res) => {
window.location.href = "/view-document";
});
}
im pretty sure these are the sections i need to change for to to work and what iv managed to work out is
routes.py
@app.route('/view-document/<name>', methods=['GET', 'POST'])
def view_document():
name = document['name'] <!--to access the neo4j database-->
document_link = active_document_link <!--i was told to get the document link from the url instead of from "active_document_link" -->
document_filepath = os.path.join('../static/sample_documents', document_link)
document = get_document_from_document_link(document_link)
user_name = get_active_user_name()
index.js
function openDocument(documentFormat, documentLink) {
fetch("/open-document", {
method: "POST",
body: JSON.stringify({ documentFormat: documentFormat, documentLink: documentLink })
}).then((_res) => {
window.location.href = "/view-document/<name>";
});
}