mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-09-06 18:01:07 +00:00
Update server.py
This commit is contained in:
parent
6616832338
commit
8133336c40
14
server.py
14
server.py
|
@ -33,19 +33,7 @@ from requests.auth import HTTPBasicAuth
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
|
||||||
from base import Extension, jsonrpc2_create_id, jsonrpc2_encode, jsonrpc2_result_encode
|
from base import Extension, extract_credentials, jsonrpc2_create_id, jsonrpc2_encode, jsonrpc2_result_encode
|
||||||
|
|
||||||
def extract_credentials(url):
|
|
||||||
pattern = re.compile(r'(?P<scheme>\w+://)?(?P<username>[^:/]+):(?P<password>[^@]+)@(?P<url>.+)')
|
|
||||||
match = pattern.match(url)
|
|
||||||
if match:
|
|
||||||
scheme = match.group('scheme') if match.group('scheme') else 'https://'
|
|
||||||
username = match.group('username')
|
|
||||||
password = match.group('password')
|
|
||||||
url = match.group('url')
|
|
||||||
return username, password, scheme + url
|
|
||||||
else:
|
|
||||||
return None, None, url
|
|
||||||
|
|
||||||
# initalization
|
# initalization
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user