DEV Community

Cover image for How I used a little Python to grab that perfect cabin weekend
Viral Shah
Viral Shah

Posted on

How I used a little Python to grab that perfect cabin weekend

Runde fyr — one of the most sought after cabins in Norway. Photo credits: Marius Dalseg

As an Indian American Norwegian living in Oslo, I have gathered a, dare I say, rather eclectic set of interests. But like every Norwegian, I do love me a great cabin weekend, especially using the gem of all public services, DNT (the Norwegian Trekking Association). They offer some absolutely epic stays throughout all of Norway, with over 500 cabins at really affordable prices.

The problem is that DNT isn’t exactly a well kept secret, and these places fill up quickly during popular travel weekends, public holidays, and throughout the summer. A brilliant developer friend of mine concocted a way to send himself emails when these cabins became available. But I had no way to get in on the action other than to bother him about adding me into the mix, having to keep reminding him, sending him my preferred dates and cabins. Pretty cumbersome!

Scenes from Flokehyttene. Photo credits: Marius Dalseg

I figured, why not build this myself? I wanted to make something I could use myself and that I could also distribute to my friends and family!

Building it

As a coding novice, Python is my language of choice to try making something that works. But with Databutton, I made something that was actually cool and that I’m proud of.

The basics of my system

I made a sign up form for myself and others to input their preferences — which cabin and dates are they interested in and which email address did they want to be notified to? Databutton bundles Streamlit, an easy tool to build nice looking web frontends, along with a simple way to store and fetch data as hosted dataframes. I don’t have to deal with a ton of services to make this work!

And of course I had to make a daily email service, testing out my parsing logic in a Jupyter notebook and transitioning things into a scheduled emailing job. This normally would be a pain, having to sign up for, learn and configure Sendgrid or some other service, but Databutton also provides a simple emailing function to ship html via email in just a few lines of code!

The code for sending an email every day 🧑‍💻

The result

I was able to book a fantastic weekend during one of the busiest travel weekends in Norway, Oslo’s fall break from school. Great success! Check out my gorgeous fall day on the Norwegian coast with the requisite Kvikk Lunsj.

A gorgeous fall day on the Norwegian coast with the requisite Kvikkl Lunsj.

If you can open a .csv in Python, you can make something just as awesome for yourself, your friends or your team 🤩

Resources

Top comments (0)