def schemas(path): """ Serve OGC schemas locally :param path: path of the OGC schema document :returns: HTTP response """ full_filepath = os.path.join(OGC_SCHEMAS_LOCATION, path) dirname_ = os.path.dirname(full_filepath) basename_ = os.path.basename(full_filepath) # TODO: better sanitization? path_ = dirname_.replace('..', '').replace('//', '') return send_from_directory(path_, basename_, mimetype=get_mimetype(basename_))
def test_mimetype(): assert util.get_mimetype('file.xml') == 'application/xml' assert util.get_mimetype('file.yml') == 'text/plain' assert util.get_mimetype('file.yaml') == 'text/plain'