Back

Python function issues

  • 0
  • Functions
Zigsonn
1 Jun, 2023, 20:43

Hello,

first time ussing appwrite functions and i am doing it in python. For testing i just created a simple function that just returns the request json. I also set that it should trigger when documents are created in a certain collection. The trigger doesn't happen and when i run the function manually i get an internal server error (404 general_route_not_found). Can anyone help?

TL;DR
User is experiencing issues with a Python function in Appwrite. They are unable to trigger the function when documents are created in a collection and receive a 404 general_route_not_found error when running the function manually. They are seeking help to resolve this issue. Solution: The user is recommended to use the Appwrite CLI to initialize and deploy their function code. They should also ensure that they have set the Endpoint, API key, and Project ID variables in the function settings page in the console. Additionally, they are provided with sample code to try for testing the triggers.
Binyamin
1 Jun, 2023, 21:13

Hey, Have you set the Endpont, API key and Project id variables in the function setting page in the console?

Zigsonn
1 Jun, 2023, 21:16

i set the api key and endpoint, i didnt set the project id because i think i saw somewhere it is included in req? also why would the function crash if i dont have a variable i dont use anyway? Or does appwrite need them when it sets up the function

Binyamin
1 Jun, 2023, 21:18

But you must have project ID for accessing Appwrite Can you share your code?

Zigsonn
1 Jun, 2023, 21:18

def main(req, res): return res.json(req.json())

Zigsonn
1 Jun, 2023, 21:18

just this right now because i wanted to test the triggers

Binyamin
1 Jun, 2023, 21:22

I don't think that req has json() function. Try to deploy this

TypeScript
def main(req, res):
    return res.json({
      'payload': req.payload,
    });
Zigsonn
1 Jun, 2023, 21:22

okay will try

Zigsonn
1 Jun, 2023, 21:26

i get the same error

Zigsonn
1 Jun, 2023, 21:26

maybe i forgot to set something up? I am running appwrite in digitalocean droplet if that helps

Binyamin
1 Jun, 2023, 21:26

What version of Appwrite you're using? Where do you get the error

Zigsonn
1 Jun, 2023, 21:26

1.3.5

Binyamin
1 Jun, 2023, 21:26

Did the function built successfully?

Zigsonn
1 Jun, 2023, 21:27

yes it did

Zigsonn
1 Jun, 2023, 21:27

the previous ones also did

Drake
1 Jun, 2023, 21:29

I highly suggest using the Appwrite CLI to initialize and deploy your function code so you have a working foundation to build on: https://appwrite.io/docs/functions#gettingStarted

Zigsonn
1 Jun, 2023, 21:31

Okay i will try that, but since it is on digitalocean, how can i edit the code?

Binyamin
1 Jun, 2023, 21:31

You will deploy it each time from your local computer

Zigsonn
1 Jun, 2023, 21:35

Ah okay thank you

Zigsonn
1 Jun, 2023, 21:38

Also a quick question, is it possible to send multiple files to a storage bucket or does each have to be sent separatly

Binyamin
1 Jun, 2023, 21:38

You mean batch upload? If so, you'll no upload one-by-one.

Zigsonn
1 Jun, 2023, 21:42

Ah okay thank you

Binyamin
1 Jun, 2023, 23:52

Btw is this what you saw, if so it can be related to that https://github.com/appwrite/appwrite/issues/5623

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more