Skip to content
Permalink
Browse files

Add static files for Open API serving (#314)

  • Loading branch information...
leonsim authored and parano committed Sep 30, 2019
1 parent 561a9a8 commit 4d201c4cd922342a5858c420ba9eae8e5ab54758
@@ -32,3 +32,4 @@ global-exclude .ipynb_checkpoints
global-exclude __pycache__
include versioneer.py
include bentoml/_version.py
recursive-include bentoml/server/static *
@@ -42,10 +42,10 @@
INDEX_HTML = '''
<!DOCTYPE html>
<head><link rel="stylesheet" type="text/css"
href="//unpkg.com/swagger-ui-dist@3/swagger-ui.css"></head>
href="/static/swagger-ui.css"></head>
<body>
<div id="swagger-ui-container"></div>
<script src="//unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
<script src="/static/swagger-ui-bundle.js"></script>
<script>
SwaggerUIBundle({{
url: '{url}',
@@ -203,7 +203,7 @@ def log_image(req, request_id):
filename = '{timestamp}-{request_id}.{ext}'.format(
timestamp=int(time.time()),
request_id=request_id,
ext=req.content_type[len(img_prefix):],
ext=req.content_type[len(img_prefix) :],
)
path = os.path.join(log_folder, filename)
all_paths.append(path)
@@ -327,7 +327,12 @@ def __init__(self, bento_service, port=_DEFAULT_PORT, app_name=None):
self.port = port
self.bento_service = bento_service

self.app = Flask(app_name)
self.app = Flask(
app_name,
static_folder=os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'static'
),
)
setup_routes(self.app, self.bento_service)

def start(self):

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 4d201c4

Please sign in to comment.
You can’t perform that action at this time.