appwrite 1.3.7 with function python 3.10 on ubuntu arm.
is not able to read variables.
here is the message when uploading .env (jusit to prove i add vars)
no function data: the code i tryid for debugging:
def main(req, res):
for key, value in os.environ.items():
print(f"{key}: {value}")
for var in req.variables:
print(var)
print(req.variables.get(var))
print(os.getenv("SECRET_KEY"))
print(req.variables.get('SECRET_KEY'))
if not req.variables.get('_APP_SMTP_HOST'):
return res.json({"success": False, "message": "missing GmailServer"})
smtp_server = req.variables.get('_APP_SMTP_HOST')
if not req.variables.get('_APP_SMTP_PORT'):
return res.json({"success": False, "message": "missing GmailPort"})
smtp_port = req.variables.get('_APP_SMTP_PORT')
if not req.variables.get('_APP_SMTP_USERNAME'):
return res.json({"success": False, "message": "missing UserId"})
smtp_username = req.variables.get('_APP_SMTP_USERNAME')
if not req.variables.get('_APP_SMTP_PASSWORD'):
return res.json({"success": False, "message": "missing UserPassword"})
smtp_password = req.variables.get('_APP_SMTP_PASSWORD')
if not req.variables.get('ReciverEmail'):
return res.json({"success": False, "message": "missing ReciverEmail"})
receiver_email = req.variables.get('ReciverEmail'
p.s you can change the vars to whatever...this was just 1 of the tests
example env file:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=someuser@bashans.net
SMTP_PASSWORD=adsomeKEY3wtbkekwy
RECIVER_EMAIL=ssomeReciver@gmail.com
Did you have tried adding the parameters manually?
Does it works that way?
Also the second screenshot doesn't seems to have an ENV var format
And also it seems you're not using the correct formatting. It should be like that:
req.variables['YOUR_ENV_VAR']
Even with python?
I think yes
According to docs
Here it uses "()"
Not sure then. In Dart
req.variables['YOUR_ENV_VAR']
seems to be working correctly. I think in python it should work too
so python 3.9 and 3.10 are not working
when i try to use dotnet
Dotnet also isnt resolving vars is set in the console
i followed this example: https://appwrite.io/docs/functions#writingYourOwnFunction
*the functioon runs, just vars are not working..
/*
'req' variable has:
'Headers' - object with request headers
'Payload' - request body data as a string
'variables' - object with function variables
'res' variable has:
'Send(text, status)' - function to return text response. Status code defaults to 200
'Json(obj, status)' - function to return JSON response. Status code defaults to 200
If an error is thrown, a response with code 500 will be returned.
*/
using System.Threading.Tasks;
using System.Collections.Generic;
public async Task<RuntimeResponse> Main(RuntimeRequest req, RuntimeResponse res)
{
// Appwrite's SDK for .NET is currently under the works and shall be available soon
var secretKey = req.Variables.ContainsKey("SECRET_KEY")
? req.Variables["SECRET_KEY"]
: "SECRET_KEY variable not found. You can set it in Function settings.";
Console.WriteLine(secretKey);
return res.Json(new()
{
{ "areDevelopersAwesome", true }
});
}
@Eldad can some one help me π¦ it runs fine, just dosent get any variable i am setting.
when trying this dotnet example "as is" https://github.com/open-runtimes/examples/tree/main/dotnet/generateShortUrl
getting the fillwing return message:
How did you run the function?
Just execute button in the ui
And wait payload you've send?
Nothing
Recommended threads
- Error When load the website
Hi, I am getting this error whenever I reload my website please help me, I am using react Error: ** GET https://cloud.appwrite.io/v1/account 401 (Unauthoriz...
- Migrate from cloud to localhost
Hello everyone. I need to migrate my test project from cloud to localhost, however it seems that this is possible only if a self-hosted appwrite instance it's h...
- Current User is Not authorized
recreating same Thread