Back

[SOLVED] A Function only support Single Python File ?

  • 0
  • Functions
Milukun
31 May, 2023, 13:55

I tried to create a new logic directory under the Python Function directory generated by CIL to place some logic, but I can't seem to reference it? So currently Function can only be run as a single file, right? Or maybe I missed something

TL;DR
Solution: The issue of the function only supporting a single Python file has been solved. One possible solution is to use the following code: ```py import os folder = os.path.dirname(os.path.realpath(__file__)) file = os.path.join(folder, 'templates.txt') open(file, 'r') ``` Additionally, it is suggested to import and export functions using specific syntax provided in the links: Import: https://github.com/open-runtimes/examples/blob/main/python/send_message/main.py#L1 Export: https://github.com/open-runtimes/examples/blob/main/python/send_message/functions/send_sms_twilio.py#
joeyouss
31 May, 2023, 15:00
Milukun
1 Jun, 2023, 02:01

Thanks, I added before the quote . It works, but it's a bit weird

Milukun
1 Jun, 2023, 02:01

[SOLVED]A Function only support Single Python File ?

Drake
1 Jun, 2023, 03:30

The dot? It's a relative import because the path is a little different in the runtime container

Milukun
6 Jun, 2023, 13:08

I got this problem again on reading file , usually it will work on with open('templates.txt','r') , but i try

Milukun
6 Jun, 2023, 13:08

many ways to call be failed

Milukun
6 Jun, 2023, 13:10
Guille
6 Jun, 2023, 14:38

I'm not really sure if this works but, what if you do this?:

TypeScript
import os 
folder = os.path.dirname(os.path.realpath(__file__))

file = os.path.join(folder, 'templates.txt')
open(file,'r')
Milukun
7 Jun, 2023, 00:18

this can be solved, thans!

Drake
7 Jun, 2023, 00:30

[SOLVED] A Function only support Single Python File ?

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