r/madeinpython • u/Humanist_NA • May 25 '21
Flask Project - Bitcoin Roller Coaster Guy
Website: https://bitcoin-meme.herokuapp.com/
GitHub: https://github.com/kickinslowly/bitcoin_meme
This is a learning project to help me understand Flask Web Framework. This is my first time using Flask. The project idea was random, I knew I wanted the site to be basic and automatically update content. I chose the Bitcoin Roller Coaster Guy because it is a pretty fun meme.
The app pings coindesk every 30 seconds to grab current price. Then displays current price and % change over the last 30 seconds. Based on % change, roller coaster guy updates his angle on the coaster. Audio files also update with coaster guy.
I used a dictionary named status to hold information for each scenario:
status = [{
'normal': {
'gif': 'static/level.gif',
'sound': ['static/minecart.mp3', 'static/woohoo.mp3', 'static/moon.mp3']
},
'down_30': {
'gif': 'static/down_30.gif',
'sound': ['static/minecart.mp3', 'static/woohoo.mp3', 'static/dip.mp3']
},
'down_60': {
'gif': 'static/down_60.gif',
'sound': ['static/minecart.mp3', 'static/woohoo.mp3', 'static/down.mp3']
},
'down': {
'gif': 'static/down.gif',
'sound': ['static/minecart.mp3', 'static/woohoo.mp3', 'static/emergency.mp3']
},
'up_30': {
'gif': 'static/up_30.gif',
'sound': ['static/minecart.mp3', 'static/woohoo.mp3', 'static/forever.mp3']
},
'up_60': {
'gif': 'static/up_60.gif',
'sound': ['static/minecart.mp3', 'static/woohoo.mp3', 'static/pump.mp3']
},
'up': {
'gif': 'static/up.gif',
'sound': ['static/minecart.mp3', 'static/yeehaw.mp3', 'static/launch.mp3']
},
}]I used if/else statements to choose status(I always feel there is a better way).
I learned immediately that I don't know much about web development, just basic html and css. I was able to string a little JavaScript together to cause the page to refresh. I know this is super clunky and ideally I would like to have each element refresh and not the whole page, but I think that requires more JS and I was more focused on creating a basic Flask app and getting it deployed.
That's all, thanks for your support.
2
4
u/lungdart May 25 '21
Awesome project! A little tip for git, i recommend the default github .gitignore for python to avoid extra files like the pycache