Skip to main content

A simple CORS proxy utility with requests-like response

Project description

jupyterlite-simple-cors-proxy

Simple CORS proxy wrapper for making http requests from JupyterLite. Uses https://corsproxy.io/

Installation

pip install jupyterlite-simple-cors-proxy

Usage

from jupyterlite_simple_cors_proxy.proxy import cors_proxy_get, robust_get_request, furl, xurl

# Set up
url = "https://api.example.com/data"
# Optional params
params = {"key": "value"}

# Get a cross-origin proxied url
cross_origin_url = xurl(url) # xurl(url, params)

# Get a file like object
# (Make the request, then create a file like object
# from the response)
file_ob = furl(url) # furl(url, params)

# Make a request
response = cors_proxy_get(url, params)

# Use like requests
print(response.text)
data = response.json()
raw = response.content

The robust_get_request() will first try a simple request, then a proxied request: robust_get_request(url, params)

Features

  • Simple CORS proxy wrapper
  • Requests response object
  • Support for URL parameters

fastf1 cors proxy

A monkey patch for fastf1 is provided as:

import fast f1
from jupyterlite_simple_cors_proxy.fastf1_proxy import enable_cors_proxy

enable_cors_proxy(
#    domains=["api.formula1.com", "livetiming.formula1.com"],
#    debug=True,
#    proxy_url="https://corsproxy.io/",
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlite_simple_cors_proxy-0.1.9.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterlite_simple_cors_proxy-0.1.9-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlite_simple_cors_proxy-0.1.9.tar.gz.

File metadata

File hashes

Hashes for jupyterlite_simple_cors_proxy-0.1.9.tar.gz
Algorithm Hash digest
SHA256 a6c42f5b5f476260795ee239dd2a87782e82cc58c6e3c66b9227564a62f0b5a4
MD5 213d44b1230ffce6f9da920bed56e4ef
BLAKE2b-256 cd6622345757367b5d8a4dfa11c8443909948fcf4083780d2eaf890b4d0df510

See more details on using hashes here.

File details

Details for the file jupyterlite_simple_cors_proxy-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlite_simple_cors_proxy-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b59e05ad429fa72c91ed21cdac5c7b45a1163d2afcae1163440b4f28b8c5d53f
MD5 774228928e2b9cec1f4f5574b88be0be
BLAKE2b-256 889e266f5738e28a2bd8f4f9931a6170e91e0f2282fb07bd0cd24c80f0b961af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page