Move css to a separate file, serve static files under /static/ route

This commit is contained in:
2021-06-03 01:05:12 +02:00
parent 7e81ea0b74
commit 2437a3f26b
3 changed files with 27 additions and 22 deletions

View File

@@ -9,12 +9,13 @@ import requests
import os
import urllib.parse
from bottle import hook, request, route, run, view
from bottle import hook, request, route, run, static_file, view
from config import conf
import models
from models import Song, AirCast, DoesNotExist
project_dir = os.path.dirname(__file__)
# ----------------------------------------------------------------------
# Util functions
@@ -112,6 +113,11 @@ def results_page():
start_time=time,
end_time = '{:0>2}:00'.format(hour+1))
@route('/static/<filename>')
def serve_static_file(filename):
static_root = os.path.join(project_dir, 'static')
return static_file(filename, root=static_root)
@hook('before_request')
def set_locale():
"""Set the locale for all categories to the first lang in Accept-Language