-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.py
50 lines (38 loc) · 1.38 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
import os
import xpublish
from fastapi.middleware.cors import CORSMiddleware
from xreds.config import settings
from xreds.plugins.export import ExportPlugin
from xreds.plugins.size_plugin import SizePlugin
from xreds.spastaticfiles import SPAStaticFiles
from xreds.dataset_provider import DatasetProvider
from xreds.plugins.subset_plugin import SubsetPlugin, SubsetSupportPlugin
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,
)
export_threshold = settings.export_threshold
rest.register_plugin(DatasetProvider())
rest.register_plugin(SubsetSupportPlugin())
rest.register_plugin(SubsetPlugin())
rest.register_plugin(SizePlugin())
rest.register_plugin(ExportPlugin())
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 = settings.root_path
if __name__ == "__main__":
import uvicorn
# When run directly, run in debug mode
uvicorn.run("app:app", host="0.0.0.0", port=8090, reload=True, log_level="debug")