
Hey I made a python cron function that's just adding values to collection, but when I deploy it, I get this error
import json
import pandas as pd
from appwrite.client import Client
from appwrite.services.databases import Database
def init_client():
# Initialize the Appwrite client
client = Client()
client.set_endpoint("https://cloud.appwrite.io/v1")
client.set_project("646769a1263324aecec0")
client.set_key("API_KEY")
return client
def main():
client = init_client()
database = Database(client)
database.create_document("646a552f4564180c1531", {
'company_name': "Utopia",
'job_title': "Software Engineer",
'about_company': "Utopia is a software company that builds software for the future",
'location': "Remote",
'skills_required': "Python, Java, C++",
'job_responsibilities': "Build software for the future",
'job_requirements': "Must have 5 years of experience",
'logo': "https://www.utopia.com/logo.png"
}, read=['*'])
if __name__ == "__main__":
main()```
Error:

This doesn't look like the right structure for an Appwrite Function. Make sure to follow the docs: https://appwrite.io/docs/functions

Oh I followed this repo, is it not updated or something? https://github.com/appwrite/demos-for-functions/blob/master/python/create_user_profile/main.py

also, according to the docs, is it necessary to return a res, cause I just want this function to directly update values in the collection?

Am I doing something wrong, even this is not deploying😫
def main(req, res):
payload = req.payload or 'No payload provided. Add custom data when executing function.'
secretKey = req.variables.get(
'api_key,
'SECRET_KEY variable not found. You can set it in Function settings.'
)
randomNumber = random.random()
# trigger = req.variables['APPWRITE_FUNCTION_TRIGGER']
return res.json({
'message': 'Hello from Appwrite!',
'payload': payload,
'secretKey': secretKey,
'Number': 123,
})```

That repo is archived

I highly recommend using the Appwrite CLI to initialize and deploy the starter python function. Then, you can tweak it accordingly
Recommended threads
- Function running in cloud but not locall...
Hi everyone, I have an appwrite function which is on python3.12 runtime. I have a library (hnswlib) which builds wheels during installation. This works on appwr...
- Permissions for bulk operation
Hi team, I have a question: “In the databases.createDocuments bulk API, can I set document-level permissions? If yes, how exactly should I include the permissio...
- Limit File Upload count?
Is there a way to limit the number of files a user can upload? I know there's a limit of file size but in my case I'd like to limit the user to only upload x am...
