Day 24 of the Anvil Advent Calendar
Build a web app every day until Christmas, with nothing but Python!
The gift of giving feedback
For todays advent of code, we built a quick app to help your friends and family give you feedback on your gifts:
https://christmas-present-feedback.anvil.app
Of course, the app is built with nothing but Python!
Here’s how it works:
For this app, we took advantage of Anvil’s RichText component. We added a few slots to the RichText and populated them with DropDowns. Each DropDown contains some suggestions for people to use in their feedback.
Then, we collect all the selections a user makes with some client-side Python and pass their feedback to a server function to store the feedback in our app’s database. We also call anvil.email.send()
to use Anvil’s built-in Email Service to send us an email with the feedback.
@anvil.server.callable
def submit_feedback(name, gift, feedback):
tables.app_tables.feedback.add_row(name=name, gift=gift, feedback=feedback)
anvil.email.send(
from_name=name,
subject=f"Feedback for {gift}",
html=f"""
From: {name}
<br>
Gift: {gift}
<br>
<br>
Feedback:
{feedback}
"""
)
Here’s how the email looks in our inbox:
And that’s all there is to it!
See the Source
Check out the source code for yourself!
Give the Gift of Python
Share this post: