Heroku and AWS

nicho | Tuesday, May 12 2020


Since the last blog post, I have started hosting this site on Heroku, as well as slightly pivoted the purpose of this blog and site. I am hoping that through this blog, potential employers can get a peak into my thought process and how I approach problems, as well as be able to look at actual projects that I have released. A lot of time has passed since the last post, in which my group for CS3240, Advanced Software and Development, finished our project for the class of a textbook exchange. Through that process I feel my knowledge of Django development increased exponentially and I want to showcase that through this website.

I have migrated all the photos from the website to upload to an AWS S3 bucket, where there is more free storage space available than with Heroku. Static CSS files have also been moved to AWS as a more reliable static file storage, as Django recommends against hosting static files through their framework. Uploading of photos is done seamlessly through the Django admin console and I never have to directly upload and link the files to Django. I also had to compile my own version of Bootstrap to get shadows working as well as making custom fonts very easy to use. I used Themestr.app for this as I have no personal experience compiling SCSS into CSS.

Finally, I added my resume to the website. With this process I transitioned it to Django models, meaning I can easily set a flag to add or remove components depending how I want my resume to appear. Hosting my resume on a website also provides an opportunity to provide a PDF version that many employers would want. Originally I had a HTML file that I would open in Chrome and print to a PDF to create a PDF. However I wanted this to be dynamically updated, so I looked into HTML to PDF converter I could use with Django. I came across wkhtmltopdf (WebKit HTML to PDF) which is a binary that many Python packages use to create a PDF from HTML code. Problems arose two times. First, wkhtmltopdf uses a very old version of WebKit , equivalent to the version that was implemented in Chrome 8. We now are on Chrome 80 as of the time of writing. In the changes to WebKit since the version in wkhtmltopdf, flex css functionality was added, which is used by Bootstrap in their row and column functionality. Luckily, after searching online, there were some simple deprecated WebKit styling options that were used in wkhtmltopdf that allowed me to restore basic functionality. The Bootstrap rows and columns are a very basic implementation of flex so this quick fix worked for PDF creation. The second problem was installing the wkhtmltopdf binary on Heroku since I develop on Windows and the binary isn't compatible with both. Installing wkhtmltopdf on Heroku is also difficult but can be solved with a buildpack which does most of the heavy lifting. Then, all I have to do is set the install location when initializing the PDF creation package, adding logic to change the install location based on whether I am on Windows or Linux.


← Back