Highlights:
- I learned the general framework for how Flask works! Including the @app.route() and render_template() functions.
- I deployed the burningvpn.com app with Google App Engine using Flask, and it works!
- Learned that restarting the systems / computer / code solves 75%+ of my problems.
Context:
In order to build some functionality into my website (Stripe payments, account management, etc.), I need to have some server-side code to run through this logic. I’d like to use Python, since I’m most familiar with that language.
There’s a ‘micro-framework’ called Flask that helps connects Python files with HTML / CSS / Javascript files. It’s an entirely new framework, so it’ll require some learning. Here I go with my learning.
Some tutorials that helped me:
https://blog.fossasia.org/integrating-stripe-in-flask/
This blog helped a lot. Spent a lot of time trying to get my form from my html page to submit to my Python file.
https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
This guy’s blog is even more helpful. But using Flask looks a lot more complicated than I imagined! This looks like it’ll take more time to learn…
https://medium.freecodecamp.org/how-to-build-a-web-application-using-flask-and-deploy-it-to-the-cloud-3551c985e492
Here’s also another good tutorial. This one’s quite good, because it also walks through setting up this web app through GAE.
Some issues I encountered:
- Issue: We have to re-arrange our .html and other files.
- Context: Currently, my workflow is I create a simple landing page on carrd.co. Once the layout is created, I’ll download the html files and other assets (pictures, .css files, etc.). After downloading the website files, I’ll upload them to our Google Apps Engine, so we can host them on burningvpn.com with SSL certificates.
- This method does not allow for interoperability with Python code. I intend to use the Stripe API with Python, since that’s the language I’m most familiar with.
- When using Flask, I have to move our .html files to a
templates
folder. This messes up the endpoints within the index.html file that I download from Carrd.
- Solution: Manually move the files and update the endpoints. Flask requires you put all of your .html files into a ‘template’ folder. All of your other assets (.css files, images, etc.) go into a
static
folder.
- Issue: I will have to make edits to our website on carrd.co in the future, since it’s easiest to arrange the layout there. So next time I make edits and download those website files to upload to my GAE, I have to make the same updates to the .html code
- Solution (for now): just do it.
- Issue: By moving all the files and updating the endpoints, I get some errors when I try to run the app locally on my computer. Perhaps I have to update the .css and .js files too?