From 3fce682c00a32a7105e23be592244031c9a06882 Mon Sep 17 00:00:00 2001 From: Krateng Date: Sun, 12 May 2019 10:20:47 +0200 Subject: [PATCH] Changed API url --- README.md | 6 +++--- scrobblers/chromium-generic/background.js | 2 +- scrobblers/chromium-generic/manifest.json | 2 +- scrobblers/chromium-generic/settings.js | 2 +- server.py | 4 ++-- website/javascript/search.js | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5ad00e2..cb21464 100644 --- a/README.md +++ b/README.md @@ -36,14 +36,14 @@ Also neat: You can use your **custom artist or track images**. If you're missing packages, the console output will tell you so. Install them. -2) (Recommended) Put your server behind a reverse proxy for SSL encryption. Configure that proxy to rewrite /db/ requests to the database port. In nginx this would look as follows: +2) (Recommended) Put your server behind a reverse proxy for SSL encryption. Configure that proxy to rewrite /api/ requests to the API port. In nginx this would look as follows: location / { proxy_pass http://yoururl:42010; } - location /db { - rewrite ^/db(.*)$ $1 break; + location /api { + rewrite ^/api(.*)$ $1 break; proxy_pass http://yoururl:42011; } diff --git a/scrobblers/chromium-generic/background.js b/scrobblers/chromium-generic/background.js index 1a26805..9c8cc89 100644 --- a/scrobblers/chromium-generic/background.js +++ b/scrobblers/chromium-generic/background.js @@ -255,7 +255,7 @@ function scrobble(artist,title,seconds) { chrome.storage.local.get("serverurl",function(result) { URL = result["serverurl"] var xhttp = new XMLHttpRequest(); - xhttp.open("POST",URL + "/db/newscrobble",true); + xhttp.open("POST",URL + "/api/newscrobble",true); xhttp.send("artist=" + artiststring + "&title=" + titlestring + "&duration=" + seconds + "&key=" + APIKEY) }); }); diff --git a/scrobblers/chromium-generic/manifest.json b/scrobblers/chromium-generic/manifest.json index c8ad406..34e70e7 100644 --- a/scrobblers/chromium-generic/manifest.json +++ b/scrobblers/chromium-generic/manifest.json @@ -1,6 +1,6 @@ { "name": "Maloja Scrobbler", - "version": "1.0", + "version": "1.1", "description": "Scrobbles tracks from various sites to your Maloja server", "manifest_version": 2, "permissions": ["activeTab", diff --git a/scrobblers/chromium-generic/settings.js b/scrobblers/chromium-generic/settings.js index 9e63405..76d6706 100644 --- a/scrobblers/chromium-generic/settings.js +++ b/scrobblers/chromium-generic/settings.js @@ -72,7 +72,7 @@ function updateAPIKey() { } function checkServer() { - url = document.getElementById("serverurl").value + "/db/test?key=" + document.getElementById("apikey").value + url = document.getElementById("serverurl").value + "/api/test?key=" + document.getElementById("apikey").value var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = createCheckmarks; diff --git a/server.py b/server.py index 92f9eed..c0c27e0 100755 --- a/server.py +++ b/server.py @@ -71,7 +71,7 @@ def customerror(error): # this is the fallback option. If you run this service behind a reverse proxy, it is recommended to rewrite /db/ requests to the port of the db server # e.g. location /db { rewrite ^/db(.*)$ $1 break; proxy_pass http://yoururl:12349; } -@webserver.get("/db/") +@webserver.get("/api/") def database_get(pth): keys = FormsDict.decode(request.query) # The Dal★Shabet handler keystring = "?" @@ -88,7 +88,7 @@ def database_get(pth): response.status = e.code return -@webserver.post("/db/") +@webserver.post("/api/") def database_post(pth): response.set_header("Access-Control-Allow-Origin","*") try: diff --git a/website/javascript/search.js b/website/javascript/search.js index c32b911..e09f5d2 100644 --- a/website/javascript/search.js +++ b/website/javascript/search.js @@ -6,7 +6,7 @@ function search(searchfield) { else { xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = searchresult - xhttp.open("GET","/db/search?max=5&query=" + encodeURIComponent(txt), true); + xhttp.open("GET","/api/search?max=5&query=" + encodeURIComponent(txt), true); xhttp.send(); } }