hosting/clore_hosting/utils.py

14 lines
349 B
Python
Raw Normal View History

2024-03-21 01:28:02 +00:00
import time
import re
from urllib.parse import urlparse
def is_valid_websocket_url(url):
regex = r'^(ws|wss)://[a-zA-Z0-9-\.]+(:\d+)?(/.*)?$'
if re.match(regex, url):
parsed_url = urlparse(url)
if parsed_url.scheme in ['ws', 'wss']:
return True
return False
def unix_timestamp():
return int(time.time())