PK! qgfra/__init__.py__version__ = '0.1.0' PK!a&&gfra/decorators/__init__.pyfrom .enabled_cors import enabled_corsPK!*gfra/decorators/enabled_cors.pyfrom flask import make_response from ..helpers import patched_wraps def enabled_cors( allowed_headers=[ "Origin", "X-Requested-With", "Content-Type", "Acccept", "Authorization", ], allowed_origin="*", allowed_methods=["GET", "POST", "HEAD", "DELETE", "OPTIONS"], ): allowed_headers_string = ", ".join(allowed_headers) allowed_methods_string = ",".join(allowed_methods) def decorator(func): @patched_wraps(func) def wrapper(*args, **kwargs): result = func(*args, **kwargs) response = make_response(result) response.headers[ "Access-Control-Allow-Headers" ] = allowed_headers_string response.headers["Access-Control-Allow-Origin"] = allowed_origin response.headers[ "Access-Control-Allow-Methods" ] = allowed_methods_string return response return wrapper return decorator PK!xMu  gfra/endpoint.pyimport logging from urllib.parse import urlparse from flask import request from flask.views import MethodView from werkzeug.exceptions import MethodNotAllowed, NotFound from werkzeug.routing import Map, Rule logger = logging.getLogger(__name__) class EndPointBase(MethodView): protected = True protected_endpoints = [] base_url = None route = "" decorators = [] def options(self, request, *args, **kwargs): return {"status": "ok"} def dispatch_request(self, *args, **kwargs): meth = getattr(self, request.method.lower(), None) if meth is None and request.method == "HEAD": meth = getattr(self, "get", None) if meth is None: raise MethodNotAllowed( description={ "title": "Method is not allowed", "detail": "Only following methods are allowed: {}.".format( ", ".join(list(self.methods)) ), } ) if not args and kwargs.get("request") is None: kwargs.update({"request": request}) if self.route and self.base_url not in request.url: server_name = urlparse(request.url_root).netloc rule = Rule(self.route) url_map = Map([rule], strict_slashes=False) matcher = url_map.bind(server_name) try: matched_data = matcher.match(request.path) except NotFound: raise NotFound( description={ "title": ( "The requested URL was not found on the server" ), "detail": ( "If you entered the URL manually please check your \ spelling and try again." ), } ) endpoint_arguments = matched_data[1] kwargs.update(endpoint_arguments) return meth(*args, **kwargs) PK!T/  gfra/helpers.pyfrom functools import WRAPPER_ASSIGNMENTS, wraps from .utils import trailing_slash def patched_wraps(func): assigned = WRAPPER_ASSIGNMENTS + ( "view_class", "methods", "provide_automatic_options", ) return wraps(func, assigned=assigned) def configure_routes(app, handlers): for handler in handlers: app.add_url_rule( trailing_slash( handler.view_class.base_url + handler.view_class.route ), view_func=handler, ) PK!-8{{ gfra/utils.pydef trailing_slash(route_path): if not route_path.endswith('/'): return route_path + '/' return route_path PK!H STTgfra-0.1.0.dist-info/WHEEL 1 0 нR. \I$ơ7.ZON `h6oi14m,b4>4ɛpK>X;baP>PK!Hty׀lgfra-0.1.0.dist-info/METADATAQO0)nb"IMU`ѠTj&INX>Ҿ> 1mL{Kwp"JUŰn(1|i{pfuY p~64x ,caASpTW#eT9/&'gv"S,N9nL hJQA҈J5wK! D9%>dm0mIK^výWd]!Kq gFZ`ߩ}'Sr:`)NDdJip_^q,aI<|t Kd\hδkt/yd3iph^4eʰJ[X% Ԭ*/IE6BtޯKQ Pu,m.Zv0 } E/:KQnN,rk*=3>뺿6bAcBqMBͪ m¶yvԱƿ;_3 vo`3w~PK!HTgfra-0.1.0.dist-info/RECORDmˎ@}? b@ ʥ醀R >ɸ=>}OҐ1IL e_u,o{/ߊUt@cc(Ֆbٷ&OǶ^ M[>xP&ꉱOtb,K8Md%n''&j'6G6VߵfsM1;֌e^Ձb7yגf|h}-j9WY b+u-Ml43(*q}Wh$rvX7[%_P