diff --git a/.gitignore b/.gitignore index 1855145..cd510d9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ src/style/github.css .envrc blog env/* -!env/template \ No newline at end of file +!env/template +.idea/ \ No newline at end of file diff --git a/philip/__init__.py b/philip/__init__.py index 6eac96d..a14ebf9 100644 --- a/philip/__init__.py +++ b/philip/__init__.py @@ -1,5 +1,5 @@ -__version__ = "0.2.2" +__version__ = "0.2.3" from philip.blueprints import philip_v1 from philip.blueprints import home diff --git a/philip/blueprints.py b/philip/blueprints.py index a6044f0..daed9df 100644 --- a/philip/blueprints.py +++ b/philip/blueprints.py @@ -1,3 +1,4 @@ +import aiohttp import os from sanic import response, Blueprint @@ -34,6 +35,10 @@ async def home(request, **kwargs): @philip_v1.route('/proxy', methods=['POST']) async def proxy(request, **kwargs): - status_code, result = await fetch(request.json["url"], - pass_through=True) + try: + status_code, result = await fetch(request.json["url"], + pass_through=True) + except aiohttp.ClientConnectorError: + status_code = 200 + result = {'error': 'Refused to connect'} return response.json(result, status=status_code)