Skip to content

Commit

Permalink
backend: added static and meta app
Browse files Browse the repository at this point in the history
  • Loading branch information
slaporte committed Jan 7, 2017
1 parent c2a1366 commit 218dee8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import clastic
import requests

from clastic import Application, redirect
from clastic import Application, redirect, StaticFileRoute, MetaApplication
from clastic.static import StaticApplication
from clastic.render import render_basic
from clastic.middleware.cookie import SignedCookieMiddleware, NEVER

Expand All @@ -21,7 +22,7 @@
DEFAULT_WIKI_API_URL = 'https://www.wikidata.org/w/api.php'
WIKI_OAUTH_URL = 'https://meta.wikimedia.org/w/index.php'
CUR_PATH = os.path.dirname(os.path.abspath(__file__))

STATIC_PATH = os.path.join(CUR_PATH, 'static')

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


def create_app():
routes = [('/', home, render_basic),
static_app = StaticApplication(STATIC_PATH)

routes = [StaticFileRoute('/', STATIC_PATH + '/index.html'),
('/', static_app),
('/home', home, render_basic),
('/login', login),
('/logout', logout),
('/complete_login', complete_login),
('/api', send_to_wd_api, render_basic)]
('/api', send_to_wd_api, render_basic),
('/meta', MetaApplication())]

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

0 comments on commit 218dee8

Please sign in to comment.