Serves static assets from each dataset root URL and switch the publicPath to be a relative path. (#1786)

This commit is contained in:
maniarathi
2020-08-22 10:04:40 -07:00
committed by GitHub
parent bc150a8469
commit 5dfe0043c3
3 changed files with 17 additions and 4 deletions
@@ -7,7 +7,7 @@ const ScriptExtHtmlWebpackPlugin = require("script-ext-html-webpack-plugin");
const src = path.resolve("src");
const nodeModules = path.resolve("node_modules");
const publicPath = "/";
const publicPath = "";
const rawObsoleteHTMLTemplate = fs.readFileSync(
`${__dirname}/obsoleteHTMLTemplate.html`,
+1 -1
View File
@@ -19,7 +19,7 @@ const Auth = React.memo((props) => {
type="button"
data-testid="auth-button"
disabled={false}
icon={!userinfo["is_authenticated"] ? "log-in" : "log-out"}
icon={!userinfo.is_authenticated ? "log-in" : "log-out"}
href={!userinfo.is_authenticated ? auth.login : auth.logout}
>
{!userinfo.is_authenticated ? "Log In" : "Log Out"}
+15 -2
View File
@@ -3,7 +3,8 @@ import logging
from functools import wraps
from http import HTTPStatus
from flask import Flask, redirect, current_app, make_response, render_template, abort, Blueprint, request
from flask import Flask, redirect, current_app, make_response, render_template, abort, Blueprint, request, \
send_from_directory
from flask_restful import Api, Resource
from server_timing import Timing as ServerTiming
@@ -335,7 +336,7 @@ class Server:
pass
def __init__(self, app_config):
self.app = Flask(__name__, static_folder="../common/web/static")
self.app = Flask(__name__, static_folder=None)
self._before_adding_routes(self.app, app_config)
self.app.json_encoder = Float32JSONEncoder
server_config = app_config.server_config
@@ -369,11 +370,23 @@ class Server:
lambda dataset, url_dataroot=url_dataroot: dataset_index(url_dataroot, dataset),
methods=["GET"],
)
self.app.add_url_rule(
f"/{url_dataroot}/<dataset>/static/<path:filename>",
f"static_assets_{url_dataroot}",
view_func=lambda dataset, filename: send_from_directory("../common/web/static", filename),
methods=["GET"]
)
else:
bp_api = Blueprint("api", __name__, url_prefix=api_version)
resources = get_api_resources(bp_api)
self.app.register_blueprint(resources.blueprint)
self.app.add_url_rule(
"/static/<path:filename>",
"static_assets",
view_func=lambda filename: send_from_directory("../common/web/static", filename),
methods=["GET"]
)
self.app.matrix_data_cache_manager = server_config.matrix_data_cache_manager
self.app.app_config = app_config