Doing live demos and coding is one of the most fun (if a little nerve wracking) parts of the job of a developer advocate. I have been doing a series of talks called "From Zero to shipped in 30 minutes" where I start with nothing but a blank IDE, and then attempt to build a working application in the allotted time.
Frequently I want to get feedback, input, or ideas from the audience. Tonight was a good example, I decided I would try and build a Wish List web application - it is coming up to Christmas after all, and it was top of mind. I wanted to get some audience participation, asking them to provide me with some links that I could use to test the app out (and maybe even get some good ideas in the process!)
There are many ways I could has asked attendees to provide that, but they all seemed very inefficient. I was thinking about this on the train journey to the event, and decided I would try and build something their and then. This blog posts outlines how I built a very simple, but effective too to help with audience participation. It is a good start, and I will try and build upon it with new features. Of course this was all possible thanks to my good friend and trust companion, Amazon Q Developer.
Using /dev to build the application
As this was going to be a simple application, I decided I would use Amazon Q Developer Agent for software development to create the initial code. I came up with the following outline of a prompt that I supplied to Amazon Q Developer via the chat interface:
I want to create a simple application that I can capture audience feedback in real time. It must
- use a Python web framework (do not use Django)
- provide a feedback link that uses a simple web interface to allow people to submit a simple message
- generate a QR code so that I can share the feedback link
- provide a messages screen that displays all the messages that people have submitted
- capture messages in a local json file that is loaded/updated as the application is stopped or started
After about 6 minutes, I have some very decent code that provides a homepage that displays a QR code, and then a separate message screen for entering feedback. After installing the requirements (/dev automatically created this for me) I had the application up and running. After a quick test to make sure it worked as intended, I realised I wanted to make a few improvements.
Improving the initial code
The first improvement was to optimise it for mobile devices. Opening up the relevant file (message.html and feedback.html), I used the following prompt in the Amazon Q Developer chat interface:
Optimise the code for mobile devices
Repeating this prompt against both those html pages resulted in much improved code that looked way better.
After testing the application I was ready to deploy it.
Deploying this to AWS
I did not want to over engineer the deployment - I needed something quick and simple. When I asked Amazon Q:
What is the easiest way to deploy this on AWS
I was guided towards deploying this using AWS AppRunner. If you are not familiar with AWS AppRunner, it is one of the simplest ways of running containerised application. I followed up with some additional prompts, such as
- Create a Dockerfile for this application
- Create a script that will build and push a container image to Amazon ECR
- Provide step by step guide on using AWS AppRunner to deploy this
And I was quickly helped in creating an ok Dockerfile*, a script that took care of all the heavily lifting (build.sh) and before long, I had the application up and running on AWS AppRunner.
*I did encounter the issue with my initial attempt in that as I was building these locally on my Arm based Macbook M1, the containers would fail as AWS AppRunner does not appear to support Arm based container images. Luckily in 2 seconds Amazon Q told me how to fix this.
I have a hosted DNS zone on Amazon Route 53, and this made it super simple to hook up a custom domain to the feedback application.
Automated updates
I had to make a few changes to the code, and every time I updated the container image via the script, AWS AppRunner would automatically redeploy the latest version. This was super awesome, especially when I was hotspotting of my iPhone when trying to do this.
Conclusion
That's all folks, in this blog post I walked you through how you can develop a simple tool to collect feedback from your audience, in less time than it took for my train to arrive at its destination. I love the way that Amazon Q Developer allows you to build anything in such a short amount of time.
If you want to try this for yourself, you can grab the code at the GitHub Repo here
You can try Amazon Q Developer for free today, by signing up for a Builder ID. You can also check out my other posts on community.aws, as I have been sharing a lot of tips and use cases of how I am using Amazon Q Developer. You can also keep up to date with all the new features and improvements of Amazon Q Developer by checking out the changelog.
update
I had a few minutes spare whilst waiting for my flight to PyCon Wroclaw, so I decided to improve this realtime feedback application. I wanted to add a profanity filter, as given that this is completely anonymous feedback, I wanted to make sure that folks used it sensible.
After opening the code in VSCode, I asked Amazon Q:
update the code so that any message is checked for profanity. Any message that container profanity is blocked
It provided me with updated code to maintain a set of words that I could exclude. Ok, so this was ok but what I really wanted to do is use one of the many open source profanity libraries available. I followed up this prompt with:
I want to use a python library to check for profanities
Which then proceeded to update the code to use one library. After running the build script, the updated version of the application now does not let folk use naughty words.
That took all of about 5 minutes, most of which was pushing the container image on the poor wifi service I have at the airport. Awesome! If this is what the future of development looks like, I love it!
Top comments (0)