jupyterlite-simple-cors-proxy 0.0.1__tar.gz → 0.1.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/PKG-INFO +16 -6
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/README.md +5 -4
- jupyterlite_simple_cors_proxy-0.1.3/jupyterlite_simple_cors_proxy/__init__.py +5 -0
- jupyterlite_simple_cors_proxy-0.1.3/jupyterlite_simple_cors_proxy/proxy.py +36 -0
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/jupyterlite_simple_cors_proxy.egg-info/PKG-INFO +16 -6
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/setup.py +1 -1
- jupyterlite_simple_cors_proxy-0.0.1/jupyterlite_simple_cors_proxy/__init__.py +0 -5
- jupyterlite_simple_cors_proxy-0.0.1/jupyterlite_simple_cors_proxy/proxy.py +0 -41
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/LICENSE +0 -0
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/jupyterlite_simple_cors_proxy.egg-info/SOURCES.txt +0 -0
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/jupyterlite_simple_cors_proxy.egg-info/dependency_links.txt +0 -0
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/jupyterlite_simple_cors_proxy.egg-info/requires.txt +0 -0
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/jupyterlite_simple_cors_proxy.egg-info/top_level.txt +0 -0
- {jupyterlite_simple_cors_proxy-0.0.1 → jupyterlite_simple_cors_proxy-0.1.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: jupyterlite-simple-cors-proxy
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.1.3
|
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
|
@@ -12,6 +12,15 @@ Requires-Python: >=3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
License-File: LICENSE
|
14
14
|
Requires-Dist: requests>=2.32.0
|
15
|
+
Dynamic: author
|
16
|
+
Dynamic: author-email
|
17
|
+
Dynamic: classifier
|
18
|
+
Dynamic: description
|
19
|
+
Dynamic: description-content-type
|
20
|
+
Dynamic: home-page
|
21
|
+
Dynamic: requires-dist
|
22
|
+
Dynamic: requires-python
|
23
|
+
Dynamic: summary
|
15
24
|
|
16
25
|
# jupyterlite-simple-cors-proxy
|
17
26
|
Simple CORS proxy for making http requests from JupyterLite
|
@@ -19,13 +28,13 @@ Simple CORS proxy for making http requests from JupyterLite
|
|
19
28
|
## Installation
|
20
29
|
|
21
30
|
```bash
|
22
|
-
pip install simple-cors-proxy
|
31
|
+
pip install jupyterlite-simple-cors-proxy
|
23
32
|
```
|
24
33
|
|
25
34
|
## Usage
|
26
35
|
|
27
36
|
```python
|
28
|
-
from simple_cors_proxy import
|
37
|
+
from simple_cors_proxy import cors_proxy_get, robust_get_request
|
29
38
|
|
30
39
|
# Make a request
|
31
40
|
url = "https://api.example.com/data"
|
@@ -38,9 +47,10 @@ data = response.json()
|
|
38
47
|
raw = response.content
|
39
48
|
```
|
40
49
|
|
50
|
+
The `robust_get_request()` will first try a simple reuqst, then a proxied request: `robust_get_request(url, params)`
|
51
|
+
|
41
52
|
## Features
|
42
53
|
|
43
54
|
- Simple CORS proxy wrapper
|
44
|
-
- Requests
|
55
|
+
- Requests response object
|
45
56
|
- 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
|
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
|
31
|
+
- Requests response object
|
30
32
|
- Support for URL parameters
|
31
|
-
- JSON parsing
|
@@ -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
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: jupyterlite-simple-cors-proxy
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.1.3
|
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
|
@@ -12,6 +12,15 @@ Requires-Python: >=3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
License-File: LICENSE
|
14
14
|
Requires-Dist: requests>=2.32.0
|
15
|
+
Dynamic: author
|
16
|
+
Dynamic: author-email
|
17
|
+
Dynamic: classifier
|
18
|
+
Dynamic: description
|
19
|
+
Dynamic: description-content-type
|
20
|
+
Dynamic: home-page
|
21
|
+
Dynamic: requires-dist
|
22
|
+
Dynamic: requires-python
|
23
|
+
Dynamic: summary
|
15
24
|
|
16
25
|
# jupyterlite-simple-cors-proxy
|
17
26
|
Simple CORS proxy for making http requests from JupyterLite
|
@@ -19,13 +28,13 @@ Simple CORS proxy for making http requests from JupyterLite
|
|
19
28
|
## Installation
|
20
29
|
|
21
30
|
```bash
|
22
|
-
pip install simple-cors-proxy
|
31
|
+
pip install jupyterlite-simple-cors-proxy
|
23
32
|
```
|
24
33
|
|
25
34
|
## Usage
|
26
35
|
|
27
36
|
```python
|
28
|
-
from simple_cors_proxy import
|
37
|
+
from simple_cors_proxy import cors_proxy_get, robust_get_request
|
29
38
|
|
30
39
|
# Make a request
|
31
40
|
url = "https://api.example.com/data"
|
@@ -38,9 +47,10 @@ data = response.json()
|
|
38
47
|
raw = response.content
|
39
48
|
```
|
40
49
|
|
50
|
+
The `robust_get_request()` will first try a simple reuqst, then a proxied request: `robust_get_request(url, params)`
|
51
|
+
|
41
52
|
## Features
|
42
53
|
|
43
54
|
- Simple CORS proxy wrapper
|
44
|
-
- Requests
|
55
|
+
- Requests response object
|
45
56
|
- Support for URL parameters
|
46
|
-
- JSON parsing
|
@@ -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)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|