mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-09 00:18:13 +08:00
#14 redirect prior to returning loading screen
This commit is contained in:
@@ -8,8 +8,9 @@
|
|||||||
# the specific language governing permissions and limitations under the License.
|
# the specific language governing permissions and limitations under the License.
|
||||||
import psutil
|
import psutil
|
||||||
import logging
|
import logging
|
||||||
|
import datetime
|
||||||
|
|
||||||
from flask import make_response, request
|
from flask import make_response, request, render_template
|
||||||
from requests import get, post, put
|
from requests import get, post, put
|
||||||
|
|
||||||
from cellxgene_gateway import env
|
from cellxgene_gateway import env
|
||||||
@@ -92,17 +93,20 @@ class CacheEntry:
|
|||||||
self.status = "terminated"
|
self.status = "terminated"
|
||||||
|
|
||||||
def serve_content(self, path):
|
def serve_content(self, path):
|
||||||
dataset = self.key.dataset
|
|
||||||
|
|
||||||
gateway_basepath = (
|
gateway_basepath = (
|
||||||
f"{env.external_protocol}://{env.external_host}/view/{self.key.pathpart}/"
|
f"{env.external_protocol}://{env.external_host}/view/{self.key.pathpart}/"
|
||||||
)
|
)
|
||||||
subpath = path[len(self.key.pathpart) :] # noqa: E203
|
subpath = path[len(self.key.pathpart) :] # noqa: E203
|
||||||
|
|
||||||
if len(subpath) == 0:
|
if len(subpath) == 0:
|
||||||
r = make_response(f"Redirect to {gateway_basepath}\n", 301)
|
r = make_response(f"Redirect to {gateway_basepath}\n", 301)
|
||||||
r.headers["location"] = gateway_basepath+querystring()
|
r.headers["location"] = gateway_basepath+querystring()
|
||||||
return r
|
return r
|
||||||
|
elif self.status == "loading":
|
||||||
|
launch_time = datetime.datetime.fromtimestamp(self.launchtime)
|
||||||
|
return render_template(
|
||||||
|
"loading.html", launchtime=launch_time, all_output=self.all_output
|
||||||
|
)
|
||||||
|
|
||||||
port = self.port
|
port = self.port
|
||||||
cellxgene_basepath = f"http://127.0.0.1:{port}"
|
cellxgene_basepath = f"http://127.0.0.1:{port}"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
# the specific language governing permissions and limitations under the License.
|
# the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
# import BaseHTTPServer
|
# import BaseHTTPServer
|
||||||
import datetime
|
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
@@ -204,13 +203,8 @@ def do_view(path):
|
|||||||
|
|
||||||
match.timestamp = current_time_stamp()
|
match.timestamp = current_time_stamp()
|
||||||
|
|
||||||
if match.status == "loaded":
|
if match.status == "loaded" or match.status == "loading":
|
||||||
return match.serve_content(path)
|
return match.serve_content(path)
|
||||||
elif match.status == "loading":
|
|
||||||
launch_time = datetime.datetime.fromtimestamp(match.launchtime)
|
|
||||||
return render_template(
|
|
||||||
"loading.html", launchtime=launch_time, all_output=match.all_output
|
|
||||||
)
|
|
||||||
elif match.status == "error":
|
elif match.status == "error":
|
||||||
raise ProcessException.from_cache_entry(match)
|
raise ProcessException.from_cache_entry(match)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user