https://github.com/nitrictech/python-sdk
Python SDK for Nitric
https://github.com/nitrictech/python-sdk
ai cloud machine-learning nitric python sdk serverless
Last synced: 7 months ago
JSON representation
Python SDK for Nitric
- Host: GitHub
- URL: https://github.com/nitrictech/python-sdk
- Owner: nitrictech
- License: apache-2.0
- Created: 2020-11-03T00:36:07.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-04T04:58:19.000Z (over 1 year ago)
- Last Synced: 2024-12-13T23:56:11.987Z (over 1 year ago)
- Topics: ai, cloud, machine-learning, nitric, python, sdk, serverless
- Language: Python
- Homepage: https://nitric.io
- Size: 1.07 MB
- Stars: 18
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Build nitric applications with Python
The Python SDK supports the use of the [Nitric](https://nitric.io) framework with Python 3.11+. For more information check out the main [Nitric repo](https://github.com/nitrictech/nitric).
Python SDKs provide an infrastructure-from-code style that lets you define resources in code. You can also write the functions that support the logic behind APIs, subscribers and schedules.
You can request the type of access you need to resources such as publishing for topics, without dealing directly with IAM or policy documents.
- Reference Documentation: https://nitric.io/docs/reference/python
- Guides: https://nitric.io/docs/guides/python
## Usage
### Starting a new project
Install the [Nitric CLI](https://nitric.io/docs/getting-started/installation), then generate your project:
```bash
nitric new hello-world py-starter
```
### Add to an existing project
First of all, you need to install the library:
**pip**
```bash
pip3 install nitric
```
**pipenv**
```
pipenv install nitric
```
Then you're able to import the library and create cloud resources:
```python
from nitric.resources import api, bucket
from nitric.application import Nitric
from nitric.context import HttpContext
publicApi = api("public")
uploads = bucket("uploads").allow("write")
@publicApi.get("/upload")
async def upload(ctx: HttpContext):
photo = uploads.file("images/photo.jpg")
url = await photo.upload_url()
ctx.res.body = {"url": url}
Nitric.run()
```
## Learn more
Learn more by checking out the [Nitric documentation](https://nitric.io/docs).
## Get in touch:
- Join us on [Discord](https://nitric.io/chat)
- Ask questions in [GitHub discussions](https://github.com/nitrictech/nitric/discussions)
- Find us on [Twitter](https://twitter.com/nitric_io)
- Send us an [email](mailto:maintainers@nitric.io)