Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noah #166

Closed
wants to merge 16 commits into from
Closed

Noah #166

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 0 additions & 154 deletions python/.gitignore

This file was deleted.

2 changes: 2 additions & 0 deletions python/text-to-speech/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
secret.py
__pycache__
72 changes: 72 additions & 0 deletions python/text-to-speech/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 🌐 Send HTTP request

A Python Cloud Function for sending an HTTP request. Supported options are method, url, body, and headers. Status code, response body, and response headers are returned.

_Example input:_

```json
{
"url":"https://demo.appwrite.io/v1/locale/countries/eu",
"method":"GET",
"headers":
{
"x-client-version":"1.0.0"
},
"body":""
}
```

_Example success output:_


```json
{
"success":true,
"response":
{
"headers":{},
"code":200,
"body":"{\"total\":27,\"countries\":[]}"
}
}
```

_Example failure output:_


```json
{
"success":false,
"message":"URL could not be reached"
}
```

## 📝 Environment Variables

No environment variables are required to run this function.

## 🚀 Deployment

1. Clone this repository, and enter this function folder:

```
$ git clone https://github.com/open-runtimes/examples.git && cd examples
$ cd python/send-http-request
```

2. Enter this function folder and build the code:
```
docker run --rm --interactive --tty --volume $PWD:/usr/code openruntimes/python:v2-3.10 sh /usr/local/src/build.sh
```
As a result, a `code.tar.gz` file will be generated.

3. Start the Open Runtime:
```
docker run -p 3000:3000 -e INTERNAL_RUNTIME_KEY=secret-key -e INTERNAL_RUNTIME_ENTRYPOINT=main.py --rm --interactive --tty --volume $PWD/code.tar.gz:/tmp/code.tar.gz:ro openruntimes/python:v2-3.10 sh /usr/local/src/start.sh
```

Your function is now listening on port `3000`, and you can execute it by sending `POST` request with appropriate authorization headers. To learn more about runtime, you can visit Python runtime [README](https://github.com/open-runtimes/open-runtimes/tree/main/runtimes/python-3.10).

## 📝 Notes
- This function is designed for use with Appwrite Cloud Functions. You can learn more about it in [Appwrite docs](https://appwrite.io/docs/functions).
- This example is compatible with Python 3.10. Other versions may work but are not guaranteed to work as they haven't been tested.
Loading