EV charge calculator from script to Dancer web

Since my last post I wanted to take my EV charge calculator script and convert it into a web form. In this post I breakdown how I migrated the script to a Dancer2 web app.

Just a minor note for those readers who may not be aware, Dancer2 is a "lightweight web-framework for Perl" as described in Dancer2 documentation and can be similar in comparison to Ruby Sinatra and Python Flask.

I started by creating a new project folder with the dancer2 program ( # please note that I am working on a Windows PC and on a linux OS the program would just be named dancer2 )

dancer2.bat -a EVCalc

I then copy over the files inside this directory to my project repository as shown in this commit and moved all the scripts to the bin directory as shown in this commit

I wrote a script to covert the electric rate csv file into a module and added all the calculation code in the main project module. All the html markup is stored in this template file and I sprinkled some CSS which renders a page similar to the screenshot below after submitting some data for calculating the charge of an EV :


Thank you for your time, I hope you enjoyed my post.

Leave a comment

About Charlie Gonzalez

user-pic I blog about Perl.