Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix domain error #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ src/style/github.css
.envrc
blog
env/*
!env/template
!env/template
.idea/
2 changes: 1 addition & 1 deletion philip/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

__version__ = "0.2.2"
__version__ = "0.2.3"

from philip.blueprints import philip_v1
from philip.blueprints import home
Expand Down
9 changes: 7 additions & 2 deletions philip/blueprints.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import aiohttp
import os

from sanic import response, Blueprint
Expand Down Expand Up @@ -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)