Skip to content

Commit 5312f9a

Browse files
committed
test4
1 parent 46e975c commit 5312f9a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

api_oc.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
# URL Mapping
5959
urls = (
6060
"/", "Main",
61+
"/static/(.*)", "Static",
6162
'/favicon.ico', 'Favicon',
6263
"/sparql/index", "SparqlIndex",
6364
"/sparql/meta", "SparqlMeta",
@@ -168,6 +169,36 @@ def GET(self):
168169
current_subdomain = web.ctx.host.split('.')[0].lower()
169170
return render.header(sp_title="", current_subdomain=current_subdomain)
170171

172+
class Static:
173+
def GET(self, name):
174+
"""Serve static files"""
175+
static_dir = "static" # o c.get("static", "static") se hai la path in conf.json
176+
file_path = os.path.join(static_dir, name)
177+
178+
if not os.path.exists(file_path):
179+
raise web.notfound()
180+
181+
# Content types
182+
ext = os.path.splitext(name)[1]
183+
content_types = {
184+
'.css': 'text/css',
185+
'.js': 'application/javascript',
186+
'.png': 'image/png',
187+
'.jpg': 'image/jpeg',
188+
'.jpeg': 'image/jpeg',
189+
'.gif': 'image/gif',
190+
'.svg': 'image/svg+xml',
191+
'.ico': 'image/x-icon',
192+
'.woff': 'font/woff',
193+
'.woff2': 'font/woff2',
194+
'.ttf': 'font/ttf',
195+
}
196+
197+
web.header('Content-Type', content_types.get(ext, 'application/octet-stream'))
198+
199+
with open(file_path, 'rb') as f:
200+
return f.read()
201+
171202
class Sparql:
172203
def __init__(self, sparql_endpoint, sparql_endpoint_title, yasqe_sparql_endpoint):
173204
self.sparql_endpoint = sparql_endpoint

docker_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.7sync-gunicorn-test3
1+
1.3.7sync-gunicorn-test4

0 commit comments

Comments
 (0)