(origin=None)
| 21 | |
| 22 | |
| 23 | def cors(origin=None): |
| 24 | CORS_HEADERS = { |
| 25 | "Access-Control-Allow-Credentials": "true", |
| 26 | "Access-Control-Allow-Methods": "GET", |
| 27 | "Access-Control-Allow-Origin": "*", |
| 28 | } |
| 29 | |
| 30 | def decorator(fn): |
| 31 | @wraps(fn) |
| 32 | def wrap(*args, **kwargs): |
| 33 | response = fn(*args, **kwargs) |
| 34 | if isinstance(response, BaseHTTPResponse): |
| 35 | response.headers.update(CORS_HEADERS) |
| 36 | return response |
| 37 | elif isawaitable(response): |
| 38 | |
| 39 | async def make_cors(): |
| 40 | r = await response |
| 41 | r.headers.update(CORS_HEADERS) |
| 42 | return r |
| 43 | |
| 44 | return make_cors() |
| 45 | return response |
| 46 | |
| 47 | return wrap |
| 48 | |
| 49 | return decorator |
| 50 | |
| 51 | |
| 52 | def parse_database_url(url): |
nothing calls this directly
no outgoing calls
no test coverage detected