jupyterlite-simple-cors-proxy 0.0.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (14) hide show
  1. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/PKG-INFO +6 -5
  2. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/README.md +5 -4
  3. jupyterlite_simple_cors_proxy-0.1.2/jupyterlite_simple_cors_proxy/__init__.py +5 -0
  4. jupyterlite_simple_cors_proxy-0.1.2/jupyterlite_simple_cors_proxy/proxy.py +36 -0
  5. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/jupyterlite_simple_cors_proxy.egg-info/PKG-INFO +6 -5
  6. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/setup.py +1 -1
  7. jupyterlite_simple_cors_proxy-0.0.1/jupyterlite_simple_cors_proxy/__init__.py +0 -5
  8. jupyterlite_simple_cors_proxy-0.0.1/jupyterlite_simple_cors_proxy/proxy.py +0 -41
  9. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/LICENSE +0 -0
  10. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/jupyterlite_simple_cors_proxy.egg-info/SOURCES.txt +0 -0
  11. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/jupyterlite_simple_cors_proxy.egg-info/dependency_links.txt +0 -0
  12. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/jupyterlite_simple_cors_proxy.egg-info/requires.txt +0 -0
  13. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/jupyterlite_simple_cors_proxy.egg-info/top_level.txt +0 -0
  14. {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jupyterlite-simple-cors-proxy
3
- Version: 0.0.1
3
+ Version: 0.1.2
4
4
  Summary: A simple CORS proxy utility with requests-like response
5
5
  Home-page: https://github.com/innovationOUtside/jupyterlite-simple-cors-proxy
6
6
  Author: Tony Hirst
@@ -19,13 +19,13 @@ Simple CORS proxy for making http requests from JupyterLite
19
19
  ## Installation
20
20
 
21
21
  ```bash
22
- pip install simple-cors-proxy
22
+ pip install jupyterlite-simple-cors-proxy
23
23
  ```
24
24
 
25
25
  ## Usage
26
26
 
27
27
  ```python
28
- from simple_cors_proxy import cors_proxy
28
+ from simple_cors_proxy import cors_proxy_get, robust_get_request
29
29
 
30
30
  # Make a request
31
31
  url = "https://api.example.com/data"
@@ -38,9 +38,10 @@ data = response.json()
38
38
  raw = response.content
39
39
  ```
40
40
 
41
+ The `robust_get_request()` will first try a simple reuqst, then a proxied request: `robust_get_request(url, params)`
42
+
41
43
  ## Features
42
44
 
43
45
  - Simple CORS proxy wrapper
44
- - Requests-like response object
46
+ - Requests response object
45
47
  - Support for URL parameters
46
- - JSON parsing
@@ -4,13 +4,13 @@ Simple CORS proxy for making http requests from JupyterLite
4
4
  ## Installation
5
5
 
6
6
  ```bash
7
- pip install simple-cors-proxy
7
+ pip install jupyterlite-simple-cors-proxy
8
8
  ```
9
9
 
10
10
  ## Usage
11
11
 
12
12
  ```python
13
- from simple_cors_proxy import cors_proxy
13
+ from simple_cors_proxy import cors_proxy_get, robust_get_request
14
14
 
15
15
  # Make a request
16
16
  url = "https://api.example.com/data"
@@ -23,9 +23,10 @@ data = response.json()
23
23
  raw = response.content
24
24
  ```
25
25
 
26
+ The `robust_get_request()` will first try a simple reuqst, then a proxied request: `robust_get_request(url, params)`
27
+
26
28
  ## Features
27
29
 
28
30
  - Simple CORS proxy wrapper
29
- - Requests-like response object
31
+ - Requests response object
30
32
  - Support for URL parameters
31
- - JSON parsing
@@ -0,0 +1,5 @@
1
+ # File: jupyterlite_simple_cors_proxy/__init__.py
2
+ from .proxy import cors_proxy, robust_get_request
3
+
4
+ __version__ = "0.1.2"
5
+ __all__ = ["cors_proxy_get", "robust_get_request"]
@@ -0,0 +1,36 @@
1
+ # File: simple_cors_proxy/proxy.py
2
+ from urllib.parse import urlencode, quote
3
+ import requests
4
+
5
+
6
+ def cors_proxy_get(url, params=None):
7
+ """
8
+ CORS proxy for GET resources with requests-like response.
9
+
10
+ Args:
11
+ url (str): The URL to fetch
12
+ params (dict, optional): Query parameters to include
13
+
14
+ Returns:
15
+ A requests response object.
16
+ """
17
+ if params:
18
+ full_url = f"{url}?{urlencode(params)}"
19
+ else:
20
+ full_url = url
21
+
22
+ proxy_url = f"https://corsproxy.io/?{quote(full_url)}"
23
+
24
+ # Do a simple requests get and
25
+ # just pass through the entire response object
26
+ return requests.get(proxy_url)
27
+
28
+ def robust_get_request(url, params=None):
29
+ """
30
+ Try to make a simple request else fall back to a proxy.
31
+ """
32
+ try:
33
+ r = requests.get(url, params=params)
34
+ except:
35
+ r = cors_proxy_get(url, params=params)
36
+ return r
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jupyterlite-simple-cors-proxy
3
- Version: 0.0.1
3
+ Version: 0.1.2
4
4
  Summary: A simple CORS proxy utility with requests-like response
5
5
  Home-page: https://github.com/innovationOUtside/jupyterlite-simple-cors-proxy
6
6
  Author: Tony Hirst
@@ -19,13 +19,13 @@ Simple CORS proxy for making http requests from JupyterLite
19
19
  ## Installation
20
20
 
21
21
  ```bash
22
- pip install simple-cors-proxy
22
+ pip install jupyterlite-simple-cors-proxy
23
23
  ```
24
24
 
25
25
  ## Usage
26
26
 
27
27
  ```python
28
- from simple_cors_proxy import cors_proxy
28
+ from simple_cors_proxy import cors_proxy_get, robust_get_request
29
29
 
30
30
  # Make a request
31
31
  url = "https://api.example.com/data"
@@ -38,9 +38,10 @@ data = response.json()
38
38
  raw = response.content
39
39
  ```
40
40
 
41
+ The `robust_get_request()` will first try a simple reuqst, then a proxied request: `robust_get_request(url, params)`
42
+
41
43
  ## Features
42
44
 
43
45
  - Simple CORS proxy wrapper
44
- - Requests-like response object
46
+ - Requests response object
45
47
  - Support for URL parameters
46
- - JSON parsing
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
3
3
 
4
4
  setup(
5
5
  name="jupyterlite-simple-cors-proxy",
6
- version="0.0.1",
6
+ version="0.1.2",
7
7
  packages=find_packages(),
8
8
  install_requires=[
9
9
  "requests>=2.32.0",
@@ -1,5 +0,0 @@
1
- # File: jupyterlite_simple_cors_proxy/__init__.py
2
- from .proxy import cors_proxy, ProxyResponse
3
-
4
- __version__ = "0.1.0"
5
- __all__ = ["cors_proxy", "ProxyResponse"]
@@ -1,41 +0,0 @@
1
- # File: simple_cors_proxy/proxy.py
2
- from urllib.parse import urlencode, quote
3
- import requests
4
-
5
- class ProxyResponse:
6
- def __init__(self, content):
7
- self._content = content
8
-
9
- @property
10
- def text(self):
11
- return self._content
12
-
13
- def json(self):
14
- import json
15
-
16
- return json.loads(self._content)
17
-
18
- @property
19
- def content(self):
20
- return self._content.encode()
21
-
22
-
23
- def cors_proxy(url, params=None):
24
- """
25
- CORS proxy for GET resources with requests-like response.
26
-
27
- Args:
28
- url (str): The URL to fetch
29
- params (dict, optional): Query parameters to include
30
-
31
- Returns:
32
- ProxyResponse: A response object with .text, .json(), and .content methods
33
- """
34
- if params:
35
- full_url = f"{url}?{urlencode(params)}"
36
- else:
37
- full_url = url
38
-
39
- proxy_url = f"https://corsproxy.io/?{quote(full_url)}"
40
- response = requests.get(proxy_url).content.decode().strip()
41
- return ProxyResponse(response)