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
- After assigning a domain to my Dart func...
I’ve attached the images. Could anyone please explain how this execution is being performed?
- I can't UNPAUSE my project with the free...
I received an email notifying me that my project had been paused due to inactivity, and the email included a link to "Restore project." However, that button red...
- Error trying to deploy functions from CL...
✗ Error • on-auth-create (6a00b2ab000c9ce2949b) • Server Error ✗ Error: No functions were pushed. Prject ID: 69ffe0270033a4ac420a