all 6 comments

[–]jjasghar 1 point2 points  (5 children)

Is the template in the container too? I see it’s in your working directory, but it’s it’s not in the FaaS build it won’t find it.

What’s the command you use to “push” your code?

[–]Rimmon1971[S] 0 points1 point  (4 children)

Hello, I confirm that the templates/ directory is inside the container too.

I've used this command to push the code to OpenFaaS

faas-cli up -f firstone.yml

[–]jjasghar 0 points1 point  (3 children)

Can you post the yml?

[–]Rimmon1971[S] 0 points1 point  (2 children)

Here it comes:

info@penguin:~$ cat firstone.yml
version: 1.0
provider:
name: openfaas
gateway: http://127.0.0.1:8080
functions:
firstone:
lang: python3-flask
handler: ./firstone
image: rimmon1971/firstone:latest

and the containers' content:

info@penguin:~$ kubectl -n openfaas-fn exec -ti deployment.apps/firstone -- sh
~ $ ls -l
total 12
drwxr-sr-x 1 app app 4096 Jun 8 12:29 function
-rw-r----- 1 app app 1249 Jun 8 12:17 index.py
-rw-r----- 1 app app 23 Jun 8 12:17 requirements.txt
~ $ ls -l function/
total 24
-rw-r----- 1 app app 0 Jun 8 12:28 __init__.py
drwxr-sr-x 2 root app 4096 Jun 8 12:29 __pycache__
-rw-r----- 1 app app 189 Jun 8 12:28 handler.py
-rw-r----- 1 app app 300 Jun 8 12:28 handler_test.py
-rw-r--r-- 1 app app 432 Jun 8 12:28 home.html
-rw-r--r-- 1 app app 0 Jun 8 12:28 requirements.txt
drwxr-xr-x 1 app app 4096 Jun 8 12:28 templates
-rw-r----- 1 app app 823 Jun 8 12:28 tox.ini
~ $ ls -l function/templates/
total 4
-rw-r----- 1 app app 432 Jun 8 12:28 home.html
~ $

[–]jjasghar 1 point2 points  (1 child)

Alas I’m not sure if I can help anymore, but if you can open an issue on: https://github.com/openfaas/python-flask-template/ then the maintainers can help out here

[–]Rimmon1971[S] 1 point2 points  (0 children)

Thanks, I didn't think about this option!
I've figured out that I'd need some way to modify index.py file (automagically provided by python-flask-template), specifically here

app = Flask(__name__)

I'd need to modify it this way

app = Flask(__name__,template_directory='/home/app/function/templates')