diff --git a/pad-bis.py b/pad-bis.py index f7ff2ed..3cfad75 100644 --- a/pad-bis.py +++ b/pad-bis.py @@ -156,13 +156,13 @@ def init_page(padliography, description): @app.route('/') def home(): '''Serve the homepage layout''' - return render_template('home.html', page=DEFAULT_PAGE) + return render_template('home.html', page=DEFAULT_PAGE, base_url=base_url) @app.route('//') def page(padliography): '''Serve a specific padliography''' - return render_template('home.html', page=padliography) + return render_template('home.html', page=padliography, base_url=base_url) @app.route('/api//', methods=['GET', 'POST']) diff --git a/static/js/PadForm.js b/static/js/PadForm.js index 7be110b..deada94 100644 --- a/static/js/PadForm.js +++ b/static/js/PadForm.js @@ -40,7 +40,7 @@ export default { pad.categories = pad.categories.join(", "); - fetch(`api/${currentPage.value}`, { + fetch(`${baseUrl.value}/api/${currentPage.value}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(pad), diff --git a/static/js/PadStore.js b/static/js/PadStore.js index ac7318e..5705394 100644 --- a/static/js/PadStore.js +++ b/static/js/PadStore.js @@ -2,7 +2,8 @@ const { ref } = Vue; const padStore = ref([]); const currentPage = ref(""); +const baseUrl = ref("") export default function padliographyStore() { - return { padStore, currentPage }; + return { padStore, currentPage, baseUrl }; } diff --git a/static/js/PadTable.js b/static/js/PadTable.js index 8dc3520..4b96626 100644 --- a/static/js/PadTable.js +++ b/static/js/PadTable.js @@ -7,13 +7,13 @@ export default { const loaded = ref(false); - const { padStore, currentPage } = padliographyStore(); + const { padStore, currentPage, baseUrl } = padliographyStore(); const newPage = ref(""); const initPage = ref(""); const pageDescription = ref(""); const initialize = function () { - fetch(`/api/${initPage.value}/init`, { + fetch(`${baseUrl.value}/api/${initPage.value}/init`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ @@ -37,7 +37,7 @@ export default { }; watchEffect(() => { - fetch(`/api/${currentPage.value}`) + fetch(`${baseUrl.value}/api/${currentPage.value}`) .then((res) => res.json()) .then((data) => { pads.value = data.pads; diff --git a/templates/home.html b/templates/home.html index b0efc31..232f3f2 100644 --- a/templates/home.html +++ b/templates/home.html @@ -15,6 +15,7 @@ +