add copyright to files in testAPI
[releng.git] / utils / test / result_collection_api / opnfv_testapi / tornado_swagger / handlers.py
1 ##############################################################################
2 # Copyright (c) 2016 ZTE Corporation
3 # feng.xiaowei@zte.com.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from tornado.web import URLSpec, StaticFileHandler
10
11 from settings import default_settings, \
12     SWAGGER_API_DOCS, SWAGGER_API_LIST, SWAGGER_API_SPEC
13 from views import SwaggerUIHandler, SwaggerResourcesHandler, SwaggerApiHandler
14
15
16 def swagger_handlers():
17     prefix = default_settings.get('swagger_prefix', '/swagger')
18     if prefix[-1] != '/':
19         prefix += '/'
20
21     def _path(suffix):
22         return prefix + suffix
23     return [
24         URLSpec(
25             _path(r'spec.html$'),
26             SwaggerUIHandler,
27             default_settings,
28             name=SWAGGER_API_DOCS),
29         URLSpec(
30             _path(r'spec.json$'),
31             SwaggerResourcesHandler,
32             default_settings,
33             name=SWAGGER_API_LIST),
34         URLSpec(
35             _path(r'spec$'),
36             SwaggerApiHandler,
37             default_settings,
38             name=SWAGGER_API_SPEC),
39         (
40             _path(r'(.*\.(css|png|gif|js))'),
41             StaticFileHandler,
42             {'path': default_settings.get('static_path')}),
43     ]