
I am new in appwrite cloud function
This is the boilerplate code when we create new python function
TypeScript
from appwrite.client import Client
# You can remove imports of services you don't use
from appwrite.services.account import Account
from appwrite.services.avatars import Avatars
from appwrite.services.databases import Databases
from appwrite.services.functions import Functions
from appwrite.services.health import Health
from appwrite.services.locale import Locale
from appwrite.services.storage import Storage
from appwrite.services.teams import Teams
from appwrite.services.users import Users
def main(req, res):
client = Client()
# You can remove services you don't use
account = Account(client)
avatars = Avatars(client)
database = Databases(client)
functions = Functions(client)
health = Health(client)
locale = Locale(client)
storage = Storage(client)
teams = Teams(client)
users = Users(client)
if not req.variables.get('APPWRITE_FUNCTION_ENDPOINT') or not req.variables.get('APPWRITE_FUNCTION_API_KEY'):
print('Environment variables are not set. Function cannot use Appwrite SDK.')
else:
(
client
.set_endpoint(req.variables.get('APPWRITE_FUNCTION_ENDPOINT', None))
.set_project(req.variables.get('APPWRITE_FUNCTION_PROJECT_ID', None))
.set_key(req.variables.get('APPWRITE_FUNCTION_API_KEY', None))
.set_self_signed(True)
)
return res.json({
"areDevelopersAwesome": True,
})
My question here is that:
- Where I can locate the [APPWRITE_FUNCTION_ENDPOINT]?
- Do I need to create APPWRITE FUNCTION API KEY environment? and If yes, how can I create api key then?
TL;DR
1. The [APPWRITE_FUNCTION_ENDPOINT] can be located in the environment variables. Make sure it is set correctly.
2. Yes, you need to create the APPWRITE FUNCTION API KEY environment variable. To create an API key, you can follow these steps:
- Go to the Appwrite dashboard.
- Navigate to the project where you want to create the API key.
- Click on the "API Keys" tab.
- Click on the "Create Key" button.
- Give a name to your API key and choose the relevant permissions.
- Click on the "Create" button.
- Copy theRecommended threads
- OAuth2 Error: invalid success param url ...
Hi everyone! I'm trying to implement Google OAuth2 login in a React Native app (using the Android simulator) with Appwrite Cloud, and I'm getting the following ...
- Trying to set up a new appwrite project
we have used the folder structure as follow Functions /function-name /src/index,js This is our entrypoint and git confugre settings When I try to run ...
- My Cloud functions domain has changed.
I want to know why the domain name of my Cloud functions has changed? I used to use appwrite.global but it suddenly became appwrite.run these days. I want to us...
