Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (34 sloc) 1.3 KB
import os.path
import sys
from datetime import datetime
from functools import wraps, update_wrapper
from flask import Flask, jsonify, make_response, send_from_directory
# We use this to prevent caching of `/api-docs.yml`
# Credits:
def nocache(view):
def no_cache(*args, **kwargs):
response = make_response(view(*args, **kwargs))
response.headers["Last-Modified"] =
response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, pre-check=0, max-age=0"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "-1"
return response
return update_wrapper(no_cache, view)
app = Flask(__name__)
SWAGGER_UI_DIST_DIR = "swagger-ui-dist"
def swagger_ui():
return send_from_directory(SWAGGER_UI_DIST_DIR, "index.html")
def swagger_assets(asset):
return send_from_directory(SWAGGER_UI_DIST_DIR, asset)
def swagger_api_docs_yml():
return send_from_directory(".", "api-docs.yml")
if __name__ == "__main__":
interface = ""
if len(sys.argv) > 1 and sys.argv[1] == "docker":
interface = "", 5000, debug=True,)