mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-02-06 15:05:00 +00:00
Update server.py
This commit is contained in:
parent
6616832338
commit
8133336c40
14
server.py
14
server.py
|
@ -33,20 +33,8 @@ from requests.auth import HTTPBasicAuth
|
|||
from urllib.parse import urlparse
|
||||
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
|
||||
try:
|
||||
listening_port = config('PORT', default=5555, cast=int)
|
||||
|
|
Loading…
Reference in New Issue
Block a user