9. Going Serverless with OpenFaaS
Activity 9: OpenFaaS Form Processor
Solution
- First, you need to create a SendGrid account and generate an API key. You can use the same API key created in the activity from Chapter 08, Introduction to Apache OpenWhisk. Refer to steps 4-7 in the activity of Chapter 08, Introduction to Apache OpenWhisk on how to create a SendGrid account and generate an API key.
- Create an OpenFaaS function named contact-form using the python3 template. This will be the frontend of the contact form:
$ faas-cli new contact-form --lang=python3
The output should be as follows:
Figure 9.59: Creating the contact-form function
- Create a new directory named html inside the contact-form directory to store the HTML files:
$ mkdir contact-form/html
The output should be as follows:
Figure 9.60: Creating the HTML folder
- Create the contact-us.html file inside the contact-form/html folder with the code provided in step 2.
- Update the
handler.py
Python file inside...