Skip to content

Commit

Permalink
Update views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dkxce authored Jun 20, 2023
1 parent af48d11 commit 35f039b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions proxy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import socket
from django.http import HttpResponse
from django.http import QueryDict
from django.views.decorators.csrf import csrf_exempt
try:
from urlparse import urlparse
except:
Expand Down Expand Up @@ -151,3 +152,21 @@ def get_headers(environ):
headers[key.replace('_', '-')] = value

return headers

@csrf_exempt
def proxy_nopath(request, *args, **kwargs):
"""
No Pass Path
Usage: path("", proxy_nopath),
Usage: re_path('(^(?!(admin|accounts|api)).*$)', proxy_nopath),
"""
return proxy_view(request, 'http://localhost:8080/', None)

@csrf_exempt
def proxy_default(request, path, *args, **kwargs):
"""
Pass Path
Usage: re_path('^proxy(?P<path>/.*)$', proxy_default),
"""
return proxy_view(request, f'http://localhost:8080{path}', None)

0 comments on commit 35f039b

Please sign in to comment.