Pyscript Dot Com
This is a utility package that allows you to interact with various PyScript.com features easily and simply without the need to handle any low-level API calls.
This module is currently in Alpha phase, and there are some caveats:
- making a proxy request or using project/account datastores may block your application until the request is finished
- micropython is currently not supported
- Potential bugs from an Alpha release
Proxies
Pyscript proxies allow you to call an endpoint created in your PyScript.com account. This is useful for calling endpoints that may require credentials or just APIs that you don't want to expose to the public.
Setting proxies
Let's first login to pyscript.com and once logged in, go to your settings and select API Proxies. Here you can create a new proxy by clicking on the Create a new API Proxy button and fill in the necessary fields.
Assume that you have created a proxy with the name cat-facts and the endpoint https://catfact.ninja/fact, the method will be GET. You can now import proxy from the pyscript_dot_com package in your pyscript app and use it to call the endpoint with the right method:
from pyscript_dot_com import proxy
response = proxy('cat-facts', 'GET')
If you print your response you will see something similar to:
{"fact":"Cats sleep 16 to 18 hours per day. When cats are asleep, they are still alert to incoming stimuli. If you poke the tail of a sleeping cat, it will respond accordingly.","length":167}
Datastores
Pyscript datastores allow you to store and retrieve data from a key-value store. Datastore behaves like a dictionary and you can store and retrieve data from it. Currently, you have three datastores that you can use:
- local - data will be stored in the user's browser
- project - data will be stored in the project storage
- account - data will be stored in your pyscript account storage
This is useful for storing data that you want to persist across multiple runs of your pyscript app or shared data between numerous pyscript apps.
Using datastores
You can import datastore from the pyscript_dot_com package in your pyscript app and use it to store and retrieve data:
from pyscript_dot_com import local, project, account
# Store data in the browser
local.datastore['name'] = 'John Doe'
# Store data in the project storage
project.datastore['project-name'] = "my-project"
# Store data in the account storage
if not account.datastore.get("my-project-views"):
account.datastore["my-project-views"] = 0
account.datastore["my-project-views"] += 1
# We can't access the project datastore from the account
project_name = account.datastore.get("project-name")
assert project_name is None
If you are curious to see how you can use both proxies and datastores, you can check this pyscript module example.
Metadata
Release files for pyscript-dot-com 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyscript_dot_com-0.0.1.tar.gz | 14.4 kB | Without provenance | Details for pyscript_dot_com-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyscript_dot_com-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for pyscript_dot_com-0.0.1-py3-none-any.whl |
Total release size: 24.9 kB
Release files / pyscript_dot_com-0.0.1.tar.gz
| Download URL | pyscript_dot_com-0.0.1.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5407ea94e247a008d38a838fbcd0ac9dcfa12e27d1114611d23fc1a7c5d2db5
|
|
BLAKE2b-256 checksum How to use checksums |
bc3851ad5855ed04453e9cd62b7f4dd7271ad713c8ef5bd6c4a82e4dd23194e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / pyscript_dot_com-0.0.1-py3-none-any.whl
| Download URL | pyscript_dot_com-0.0.1-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
578beba26cc381f832adac0663c35de4171262083dbeed7c108058d5965fc504
|
|
BLAKE2b-256 checksum How to use checksums |
5f77efe33d890295a2f931fb6f9f5b002fdd2d7ca8b1ef5477d5bc34c4ed88a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for pyscript-dot-com 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.