diff options
| -rw-r--r-- | .gitignore | 52 | ||||
| -rwxr-xr-x | backend/server.py | 28 | ||||
| -rwxr-xr-x | backend/tilo.py | 2 | ||||
| -rw-r--r-- | backend/tolData/README.md (renamed from backend/data/README.md) | 0 | ||||
| -rwxr-xr-x | backend/tolData/addPickedNames.py (renamed from backend/data/addPickedNames.py) | 0 | ||||
| -rw-r--r-- | backend/tolData/dbpedia/README.md (renamed from backend/data/dbpedia/README.md) | 0 | ||||
| -rwxr-xr-x | backend/tolData/dbpedia/genDescData.py (renamed from backend/data/dbpedia/genDescData.py) | 0 | ||||
| -rw-r--r-- | backend/tolData/enwiki/README.md (renamed from backend/data/enwiki/README.md) | 0 | ||||
| -rwxr-xr-x | backend/tolData/enwiki/downloadImgLicenseInfo.py (renamed from backend/data/enwiki/downloadImgLicenseInfo.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/enwiki/downloadImgs.py (renamed from backend/data/enwiki/downloadImgs.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/enwiki/genDescData.py (renamed from backend/data/enwiki/genDescData.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/enwiki/genDumpIndexDb.py (renamed from backend/data/enwiki/genDumpIndexDb.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/enwiki/genImgData.py (renamed from backend/data/enwiki/genImgData.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/enwiki/lookupPage.py (renamed from backend/data/enwiki/lookupPage.py) | 0 | ||||
| -rw-r--r-- | backend/tolData/eol/README.md (renamed from backend/data/eol/README.md) | 0 | ||||
| -rwxr-xr-x | backend/tolData/eol/downloadImgs.py (renamed from backend/data/eol/downloadImgs.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/eol/genImagesListDb.sh (renamed from backend/data/eol/genImagesListDb.sh) | 0 | ||||
| -rwxr-xr-x | backend/tolData/eol/reviewImgs.py (renamed from backend/data/eol/reviewImgs.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/genDbpData.py (renamed from backend/data/genDbpData.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/genEnwikiDescData.py (renamed from backend/data/genEnwikiDescData.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/genEnwikiNameData.py (renamed from backend/data/genEnwikiNameData.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/genEolNameData.py (renamed from backend/data/genEolNameData.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/genImgs.py (renamed from backend/data/genImgs.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/genLinkedImgs.py (renamed from backend/data/genLinkedImgs.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/genOtolData.py (renamed from backend/data/genOtolData.py) | 0 | ||||
| -rwxr-xr-x | backend/tolData/genReducedTrees.py (renamed from backend/data/genReducedTrees.py) | 0 | ||||
| -rw-r--r-- | backend/tolData/otol/README.md (renamed from backend/data/otol/README.md) | 0 | ||||
| -rw-r--r-- | backend/tolData/pickedImgs/README.md (renamed from backend/data/pickedImgs/README.md) | 0 | ||||
| -rwxr-xr-x | backend/tolData/reviewImgsToGen.py (renamed from backend/data/reviewImgsToGen.py) | 0 | ||||
| -rw-r--r-- | src/lib.ts | 6 | ||||
| -rw-r--r-- | vite.config.js | 2 |
31 files changed, 55 insertions, 35 deletions
@@ -4,30 +4,30 @@ /public/img/ # Backend files -/backend/data/data.db -/backend/data/otol/*.tgz -/backend/data/otol/*.json -/backend/data/otol/*.tre -/backend/data/eol/*.tgz -/backend/data/eol/*.csv -/backend/data/eol/imagesList/ -/backend/data/eol/*.db -/backend/data/eol/imgsForReview/ -/backend/data/eol/imgs/ -/backend/data/dbpedia/*.bz2 -/backend/data/dbpedia/*.db -/backend/data/enwiki/*.bz2 -/backend/data/enwiki/*.db -/backend/data/enwiki/imgs/ -/backend/data/imgList.txt -/backend/data/pickedImgs/ -/backend/data/img/ -/backend/data/pickedOtolNames.txt -/backend/data/pickedEolIds.txt -/backend/data/pickedEolAltsToSkip.txt -/backend/data/pickedEnwikiNamesToSkip.txt -/backend/data/pickedDbpLabels.txt -/backend/data/pickedEnwikiLabels.txt -/backend/data/pickedNodes.txt -/backend/data/pickedNames.txt +/backend/tolData/data.db +/backend/tolData/otol/*.tgz +/backend/tolData/otol/*.json +/backend/tolData/otol/*.tre +/backend/tolData/eol/*.tgz +/backend/tolData/eol/*.csv +/backend/tolData/eol/imagesList/ +/backend/tolData/eol/*.db +/backend/tolData/eol/imgsForReview/ +/backend/tolData/eol/imgs/ +/backend/tolData/dbpedia/*.bz2 +/backend/tolData/dbpedia/*.db +/backend/tolData/enwiki/*.bz2 +/backend/tolData/enwiki/*.db +/backend/tolData/enwiki/imgs/ +/backend/tolData/imgList.txt +/backend/tolData/pickedImgs/ +/backend/tolData/img/ +/backend/tolData/pickedOtolNames.txt +/backend/tolData/pickedEolIds.txt +/backend/tolData/pickedEolAltsToSkip.txt +/backend/tolData/pickedEnwikiNamesToSkip.txt +/backend/tolData/pickedDbpLabels.txt +/backend/tolData/pickedEnwikiLabels.txt +/backend/tolData/pickedNodes.txt +/backend/tolData/pickedNames.txt /backend/__pycache__ diff --git a/backend/server.py b/backend/server.py index a00ab7f..5e0b80f 100755 --- a/backend/server.py +++ b/backend/server.py @@ -1,18 +1,38 @@ #!/usr/bin/python3 -import sys -from wsgiref.simple_server import make_server +import sys, os +from wsgiref import simple_server, util +import mimetypes from tilo import application usageInfo = f""" Usage: {sys.argv[0]} -Runs a basic dev server that serves a WSGI script +Runs a basic dev server that serves a WSGI script and image files """ if len(sys.argv) > 1: print(usageInfo, file=sys.stderr) sys.exit(1) -with make_server('', 8000, application) as httpd: +def wrappingApp(environ, start_response): + urlPath = environ["PATH_INFO"] + if urlPath.startswith("/data/"): + # Run WSGI script + return application(environ, start_response) + elif urlPath.startswith("/tolData/img/"): + # Serve image file + imgPath = os.path.join(os.getcwd(), urlPath[1:]) + if os.path.exists(imgPath): + imgType = mimetypes.guess_type(imgPath)[0] + start_response("200 OK", [("Content-type", imgType)]) + return util.FileWrapper(open(imgPath, "rb")) + else: + start_response("404 Not Found", [("Content-type", "text/plain")]) + return [b"No image found"] + else: + start_response("404 Not Found", [("Content-type", "text/plain")]) + return [b"Unrecognised path"] + +with simple_server.make_server('', 8000, wrappingApp) as httpd: print("Serving HTTP on port 8000...") httpd.serve_forever() diff --git a/backend/tilo.py b/backend/tilo.py index f2a177e..7b0f8aa 100755 --- a/backend/tilo.py +++ b/backend/tilo.py @@ -5,7 +5,7 @@ import urllib.parse import sqlite3 import gzip, jsonpickle -dbFile = "data/data.db" +dbFile = "tolData/data.db" DEFAULT_SUGG_LIM = 5 MAX_SUGG_LIM = 50 ROOT_NAME = "cellular organisms" diff --git a/backend/data/README.md b/backend/tolData/README.md index ba64114..ba64114 100644 --- a/backend/data/README.md +++ b/backend/tolData/README.md diff --git a/backend/data/addPickedNames.py b/backend/tolData/addPickedNames.py index d56a0cb..d56a0cb 100755 --- a/backend/data/addPickedNames.py +++ b/backend/tolData/addPickedNames.py diff --git a/backend/data/dbpedia/README.md b/backend/tolData/dbpedia/README.md index 8a08f20..8a08f20 100644 --- a/backend/data/dbpedia/README.md +++ b/backend/tolData/dbpedia/README.md diff --git a/backend/data/dbpedia/genDescData.py b/backend/tolData/dbpedia/genDescData.py index d9e8a80..d9e8a80 100755 --- a/backend/data/dbpedia/genDescData.py +++ b/backend/tolData/dbpedia/genDescData.py diff --git a/backend/data/enwiki/README.md b/backend/tolData/enwiki/README.md index 90d16c7..90d16c7 100644 --- a/backend/data/enwiki/README.md +++ b/backend/tolData/enwiki/README.md diff --git a/backend/data/enwiki/downloadImgLicenseInfo.py b/backend/tolData/enwiki/downloadImgLicenseInfo.py index 399922e..399922e 100755 --- a/backend/data/enwiki/downloadImgLicenseInfo.py +++ b/backend/tolData/enwiki/downloadImgLicenseInfo.py diff --git a/backend/data/enwiki/downloadImgs.py b/backend/tolData/enwiki/downloadImgs.py index 8fb605f..8fb605f 100755 --- a/backend/data/enwiki/downloadImgs.py +++ b/backend/tolData/enwiki/downloadImgs.py diff --git a/backend/data/enwiki/genDescData.py b/backend/tolData/enwiki/genDescData.py index b0ca272..b0ca272 100755 --- a/backend/data/enwiki/genDescData.py +++ b/backend/tolData/enwiki/genDescData.py diff --git a/backend/data/enwiki/genDumpIndexDb.py b/backend/tolData/enwiki/genDumpIndexDb.py index 3955885..3955885 100755 --- a/backend/data/enwiki/genDumpIndexDb.py +++ b/backend/tolData/enwiki/genDumpIndexDb.py diff --git a/backend/data/enwiki/genImgData.py b/backend/tolData/enwiki/genImgData.py index dedfe14..dedfe14 100755 --- a/backend/data/enwiki/genImgData.py +++ b/backend/tolData/enwiki/genImgData.py diff --git a/backend/data/enwiki/lookupPage.py b/backend/tolData/enwiki/lookupPage.py index 1a90851..1a90851 100755 --- a/backend/data/enwiki/lookupPage.py +++ b/backend/tolData/enwiki/lookupPage.py diff --git a/backend/data/eol/README.md b/backend/tolData/eol/README.md index 8c527a8..8c527a8 100644 --- a/backend/data/eol/README.md +++ b/backend/tolData/eol/README.md diff --git a/backend/data/eol/downloadImgs.py b/backend/tolData/eol/downloadImgs.py index 96bc085..96bc085 100755 --- a/backend/data/eol/downloadImgs.py +++ b/backend/tolData/eol/downloadImgs.py diff --git a/backend/data/eol/genImagesListDb.sh b/backend/tolData/eol/genImagesListDb.sh index 87dd840..87dd840 100755 --- a/backend/data/eol/genImagesListDb.sh +++ b/backend/tolData/eol/genImagesListDb.sh diff --git a/backend/data/eol/reviewImgs.py b/backend/tolData/eol/reviewImgs.py index ecdf7ab..ecdf7ab 100755 --- a/backend/data/eol/reviewImgs.py +++ b/backend/tolData/eol/reviewImgs.py diff --git a/backend/data/genDbpData.py b/backend/tolData/genDbpData.py index df3a6be..df3a6be 100755 --- a/backend/data/genDbpData.py +++ b/backend/tolData/genDbpData.py diff --git a/backend/data/genEnwikiDescData.py b/backend/tolData/genEnwikiDescData.py index d3f93ed..d3f93ed 100755 --- a/backend/data/genEnwikiDescData.py +++ b/backend/tolData/genEnwikiDescData.py diff --git a/backend/data/genEnwikiNameData.py b/backend/tolData/genEnwikiNameData.py index 7ad61d1..7ad61d1 100755 --- a/backend/data/genEnwikiNameData.py +++ b/backend/tolData/genEnwikiNameData.py diff --git a/backend/data/genEolNameData.py b/backend/tolData/genEolNameData.py index dd33ee0..dd33ee0 100755 --- a/backend/data/genEolNameData.py +++ b/backend/tolData/genEolNameData.py diff --git a/backend/data/genImgs.py b/backend/tolData/genImgs.py index ecca8e0..ecca8e0 100755 --- a/backend/data/genImgs.py +++ b/backend/tolData/genImgs.py diff --git a/backend/data/genLinkedImgs.py b/backend/tolData/genLinkedImgs.py index a8e1322..a8e1322 100755 --- a/backend/data/genLinkedImgs.py +++ b/backend/tolData/genLinkedImgs.py diff --git a/backend/data/genOtolData.py b/backend/tolData/genOtolData.py index b5e0055..b5e0055 100755 --- a/backend/data/genOtolData.py +++ b/backend/tolData/genOtolData.py diff --git a/backend/data/genReducedTrees.py b/backend/tolData/genReducedTrees.py index a921be4..a921be4 100755 --- a/backend/data/genReducedTrees.py +++ b/backend/tolData/genReducedTrees.py diff --git a/backend/data/otol/README.md b/backend/tolData/otol/README.md index 4be2fd2..4be2fd2 100644 --- a/backend/data/otol/README.md +++ b/backend/tolData/otol/README.md diff --git a/backend/data/pickedImgs/README.md b/backend/tolData/pickedImgs/README.md index dfe192b..dfe192b 100644 --- a/backend/data/pickedImgs/README.md +++ b/backend/tolData/pickedImgs/README.md diff --git a/backend/data/reviewImgsToGen.py b/backend/tolData/reviewImgsToGen.py index de592f5..de592f5 100755 --- a/backend/data/reviewImgsToGen.py +++ b/backend/tolData/reviewImgsToGen.py @@ -7,11 +7,11 @@ import {LayoutOptions} from './layout'; import {getBreakpoint, Breakpoint, getScrollBarWidth, onTouchDevice} from './util'; // For server requests -const SERVER_URL = (new URL(window.location.href)).origin + '/data' -const SERVER_IMG_PATH = '/img/' +const SERVER_DATA_URL = (new URL(window.location.href)).origin + '/data/' +const SERVER_IMG_PATH = '/tolData/img/' export async function queryServer(params: URLSearchParams){ // Construct URL - let url = new URL(SERVER_URL); + let url = new URL(SERVER_DATA_URL); url.search = params.toString(); // Query server let responseObj; diff --git a/vite.config.js b/vite.config.js index 7352973..af88991 100644 --- a/vite.config.js +++ b/vite.config.js @@ -5,7 +5,7 @@ export default defineConfig({ base: '/', plugins: [vue()], server: { - proxy: {'/data': 'http://localhost:8000'}, + proxy: {'/data': 'http://localhost:8000', '/tolData': 'http://localhost:8000', }, watch: { ignored: ['**/backend', '**/public'] }, |
