Skip to content

Commit 3dd4f36

Browse files
committed
backend: added static and meta app
1 parent 6e6da0d commit 3dd4f36

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

monumental/server.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import clastic
1111
import requests
1212

13-
from clastic import Application, redirect
13+
from clastic import Application, redirect, StaticFileRoute, MetaApplication
14+
from clastic.static import StaticApplication
1415
from clastic.render import render_basic
1516
from clastic.middleware.cookie import SignedCookieMiddleware, NEVER
1617

@@ -21,7 +22,7 @@
2122
DEFAULT_WIKI_API_URL = 'https://www.wikidata.org/w/api.php'
2223
WIKI_OAUTH_URL = 'https://meta.wikimedia.org/w/index.php'
2324
CUR_PATH = os.path.dirname(os.path.abspath(__file__))
24-
25+
STATIC_PATH = os.path.join(CUR_PATH, 'static')
2526

2627
def home(cookie, request):
2728
headers = dict([(k, v) for k, v in
@@ -156,11 +157,16 @@ def send_to_wd_api(request, cookie, consumer_token):
156157

157158

158159
def create_app():
159-
routes = [('/', home, render_basic),
160+
static_app = StaticApplication(STATIC_PATH)
161+
162+
routes = [StaticFileRoute('/', STATIC_PATH + '/index.html'),
163+
('/', static_app),
164+
('/home', home, render_basic),
160165
('/login', login),
161166
('/logout', logout),
162167
('/complete_login', complete_login),
163-
('/api', send_to_wd_api, render_basic)]
168+
('/api', send_to_wd_api, render_basic),
169+
('/meta', MetaApplication())]
164170

165171
config_file_name = 'config.local.yaml'
166172
config_file_path = os.path.join(os.path.dirname(CUR_PATH), config_file_name)

0 commit comments

Comments
 (0)