{"id":25553791,"url":"https://github.com/spinframework/spin-python-sdk","last_synced_at":"2025-02-28T08:32:14.459Z","repository":{"id":104355799,"uuid":"581300829","full_name":"spinframework/spin-python-sdk","owner":"spinframework","description":"Spin SDK for Python","archived":false,"fork":false,"pushed_at":"2025-01-27T22:55:56.000Z","size":680,"stargazers_count":37,"open_issues_count":5,"forks_count":11,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-02-20T12:02:04.800Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://developer.fermyon.com/spin/v2/python-components","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spinframework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2022-12-22T20:05:34.000Z","updated_at":"2025-02-15T17:13:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"3871972a-1be3-457d-bbee-83e7f3298bb1","html_url":"https://github.com/spinframework/spin-python-sdk","commit_stats":null,"previous_names":["spinframework/spin-python-sdk"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinframework%2Fspin-python-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinframework%2Fspin-python-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinframework%2Fspin-python-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinframework%2Fspin-python-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spinframework","download_url":"https://codeload.github.com/spinframework/spin-python-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241124516,"owners_count":19913837,"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":[],"created_at":"2025-02-20T12:01:40.235Z","updated_at":"2025-02-28T08:32:14.440Z","avatar_url":"https://github.com/spinframework.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Spin Python SDK\n\nThis is an SDK for creating [Spin](https://github.com/fermyon/spin) apps using Python.\n\nNote that this SDK supersedes an earlier, experimental version, which may be\nfound in the [old-sdk](https://github.com/fermyon/spin-python-sdk/tree/old-sdk)\nbranch.\n\n## [API Documentation](https://fermyon.github.io/spin-python-sdk/v3/index.html)\n\n## Example\n\n### Prerequisites\n\n- [Python 3.10 or later and pip](https://www.python.org/downloads/)\n- [componentize-py](https://pypi.org/project/componentize-py/)\n- [spin-sdk](https://pypi.org/project/spin-sdk/)\n- [Spin](https://github.com/fermyon/spin) 2.2 or later.\n- [MyPy](https://pypi.org/project/mypy/) -- This is optional, but useful for during development.\n\nOnce you have Python and pip installed, you can use the latter to create and\nenter a virtual environment and then install the desired packages\n\n```shell\npython -m venv .venv\nsource .venv/bin/activate\npip install componentize-py==0.16.0 spin-sdk==3.3.0 mypy==1.8.0\n```\n\n### Hello, World\n\nA minimal app requires two files: a `spin.toml` and a Python script, which we'll\nname `app.py`:\n\n```shell\ncat \u003espin.toml \u003c\u003cEOF\nspin_manifest_version = 2\n\n[application]\nname = \"hello\"\nversion = \"0.1.0\"\nauthors = [\"Dev Eloper \u003cdev@example.com\u003e\"]\n\n[[trigger.http]]\nroute = \"/...\"\ncomponent = \"hello\"\n\n[component.hello]\nsource = \"app.wasm\"\n[component.hello.build]\ncommand = \"componentize-py -w spin-http componentize app -o app.wasm\"\nEOF\n```\n\n```shell\ncat \u003eapp.py \u003c\u003cEOF\nfrom spin_sdk import http\nfrom spin_sdk.http import Request, Response\n\nclass IncomingHandler(http.IncomingHandler):\n    def handle_request(self, request: Request) -\u003e Response:\n        return Response(\n            200,\n            {\"content-type\": \"text/plain\"},\n            bytes(\"Hello from Python!\", \"utf-8\")\n        )\nEOF\n```\n\nOnce you've created those files, you can check, build, and run your app:\n\n```.py\npython -m mypy app.py\nspin build -u\n```\n\nFinally, you can test your app using e.g. `curl` in another terminal:\n\n```shell\ncurl -i http://127.0.0.1:3000\n```\n\nIf all goes well, you should see something like:\n\n```\nHTTP/1.1 200 OK\ncontent-type: text/plain\ncontent-length: 18\ndate: Thu, 11 Apr 2024 17:42:31 GMT\n\nHello from Python!\n```\n\nPlease file an issue if you have any trouble.\n\nSee the [examples directory](https://github.com/fermyon/spin-python-sdk/tree/main/examples) in the repository for more examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspinframework%2Fspin-python-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspinframework%2Fspin-python-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspinframework%2Fspin-python-sdk/lists"}