forked from asascience-open/xreds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
57 lines (43 loc) · 1.3 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import logging
import os
import xpublish
from fastapi.middleware.cors import CORSMiddleware
from xreds.spastaticfiles import SPAStaticFiles
from xreds.dataset_provider import DatasetProvider
logger = logging.getLogger("uvicorn")
gunicorn_logger = logging.getLogger('gunicorn.error')
logger.handlers = gunicorn_logger.handlers
if __name__ != "main":
logger.setLevel(gunicorn_logger.level)
else:
logger.setLevel(logging.DEBUG)
rest = xpublish.Rest(
app_kws=dict(
title='XREDS',
description='XArray Environmental Data Services exposes environmental model data in common data formats for digestion in applications and notebooks',
openapi_url='/xreds.json'
),
cache_kws=dict(available_bytes=1e9),
datasets=None
)
rest.register_plugin(DatasetProvider())
app = rest.app
app.add_middleware(
CORSMiddleware,
allow_origins=['*'],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.mount("/", SPAStaticFiles(directory="./viewer/dist", html=True), name="viewer")
app.root_path = os.environ.get('ROOT_PATH')
if __name__ == '__main__':
import uvicorn
# When run directly, run in debug mode
uvicorn.run(
"app:app",
port = 8090,
reload = True,
log_level = 'debug',
debug = True
)