{"id":21547142,"url":"https://github.com/fabiorosado/pyscript_dot_com","last_synced_at":"2025-03-18T01:45:23.056Z","repository":{"id":220000332,"uuid":"750486831","full_name":"FabioRosado/pyscript_dot_com","owner":"FabioRosado","description":"Package to use PyScript.com features in a simple and easy way","archived":false,"fork":false,"pushed_at":"2024-03-12T16:41:10.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T09:23:58.135Z","etag":null,"topics":["pyscript"],"latest_commit_sha":null,"homepage":"https://pyscript.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FabioRosado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-30T18:29:05.000Z","updated_at":"2024-03-12T16:52:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"c41e936e-32ed-4a1a-8d56-dae1aed9a9e6","html_url":"https://github.com/FabioRosado/pyscript_dot_com","commit_stats":null,"previous_names":["fabiorosado/pyscript_dot_com"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FabioRosado%2Fpyscript_dot_com","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FabioRosado%2Fpyscript_dot_com/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FabioRosado%2Fpyscript_dot_com/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FabioRosado%2Fpyscript_dot_com/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FabioRosado","download_url":"https://codeload.github.com/FabioRosado/pyscript_dot_com/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244141582,"owners_count":20404835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pyscript"],"created_at":"2024-11-24T06:14:17.012Z","updated_at":"2025-03-18T01:45:23.020Z","avatar_url":"https://github.com/FabioRosado.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pyscript Dot Com\n\nThis 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.\n\nThis module is currently in Alpha phase, and there are some caveats:\n- making a proxy request or using project/account datastores may block your application until the request is finished\n- micropython is currently not supported\n- Potential bugs from an Alpha release\n\n## Proxies\n\nPyscript 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.\n\n### Setting proxies\n\nLet's first [login to pyscript.com](https://pyscript.com/) and once logged in, go to your [settings](https://pyscript.com/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.\n\nAssume 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:\n\n```python\nfrom pyscript_dot_com import proxy\n\nresponse = proxy('cat-facts', 'GET')\n```\n\nIf you print your response you will see something similar to:\n\n```\n{\"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}\n```\n\n\n## Datastores\n\nPyscript 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:\n\n- **local** - data will be stored in the user's browser\n- **project** - data will be stored in the project storage\n- **account** - data will be stored in your pyscript account storage\n\nThis is useful for storing data that you want to persist across multiple runs of your pyscript app or shared data between numerous pyscript apps.\n\n### Using datastores\n\nYou can import `datastore` from the `pyscript_dot_com` package in your pyscript app and use it to store and retrieve data:\n\n```python\n\nfrom pyscript_dot_com import local, project, account\n\n# Store data in the browser\nlocal.datastore['name'] = 'John Doe'\n\n# Store data in the project storage\nproject.datastore['project-name'] = \"my-project\"\n\n# Store data in the account storage\nif not account.datastore.get(\"my-project-views\"):\n    account.datastore[\"my-project-views\"] = 0\naccount.datastore[\"my-project-views\"] += 1\n\n# We can't access the project datastore from the account\nproject_name = account.datastore.get(\"project-name\")\nassert project_name is None\n\n```\n\nIf you are curious to see how you can use both proxies and datastores, you can check this [pyscript module example](https://pyscript.com/@fabiorosado/pyscript-module/latest).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiorosado%2Fpyscript_dot_com","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiorosado%2Fpyscript_dot_com","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiorosado%2Fpyscript_dot_com/lists"}