I wanted to figure out what bedtime would be on any planet. I was inspired by Carl's Sagan's quote about the earth being a Pale Blue Dot. How everything you know and love is a small piece of the vast universe. I wanted to be able to show that visualized.

What it does

This app is supposed to let you input a planet or a location and gives you when nightime is using the Skyfield astronomy api. That uses astronomical data to find what the nighttime is. is used to figure out your location. Using the Nasa API you could also find the position of satellites above your current location or how far the closest astronomical object is. You could put in your birthday and it would tell you what the weather was on mars that day. Astropy is another api that allows you to access astronomy data and data from Nasa as well.

How I built it

I used flask and the apis and ngrok. The server and all python libraries like numpy, pandas,matplotlib runs on a raspberry pi. The nasa public api is used to find astronomical events close to a date you enter, or your birthday. would help track your location if you wanted to find satellites above your head. The Skyfield api is actually dependent on numpy and pandas for data manipulation. Astropy was used for more information handling.

Challenges I ran into

Understanding how to do input in flask. Time management and working from home when you have to go places. I don't know web development and Json parsing and so figuring out how to show the data I am able to access is the hardest part. I am still learning how to incorporate data from APIs and parse them and then show them on the webpage. The standalone python scripts can access the data and can print out in command line, but I wasn't sure how to translate that into input and output from webpage. The biggest challenge was time however, with enough time, exploring the Nasa Api and learning flask development would make the project come together. The biggest challenge was simply not knowing the HTML/CSS/Javascript side of how to incorporate data onto a webpage.

The redirect was initially not working for me for some reason to my ngrok. And I am still unable to enforce SSL from (While my ngrok page is secure). So I have kept a link to the ngrok as well. ( is the domain I registered) The SSL not being able to be enforced is causing a security prompt in chrome not and saying "this is unsafe", while my actual site is SSL secured.

Accomplishments that I'm proud of

I was able to incorporate the Skyfield Api which is specifically made for astronomy and at least show a proof of concept based on a hard coded location in the flask python script.

What I learned

Web development is hard. Most of the time is spent on understanding APIs and parsing output from get/post requests. Even with flask, understanding HTML and CSS and Javascript is essential if you want your webpage to actually do something. I did learn how to use a data format used specifically in astronomy, and it was fun learning about that.

What's next for When is bedtime

Clean up the user experience and present the data in a nicer format. I don't know if exposing a jupyter notebook publicly would be a good idea from a security standpoint. A lot of my initial testing was through a jupyter notebook.

Built With

Share this project: