My very basic experience toying around with the framework

Recently I’ve been working on a portfolio website. I wanted to add a backend to the application, but instead of using technologies that I’ve worked with before (RoR for example), I decided to try to learn a bit of Flask. Flask is a microframework using the Python language that “aims to keep the core simple but extensible.”

Before getting started, I had to set up a virtual environment to handle dependencies and install Flask. The terminal command “pip install flask” will install the dependency for you. Pip is a similar dependency system to npm in javascript or Ruby’s gems.

Within the file I import the dependency that I just installed. This is similar to requiring dependencies in other languages such as javascript. Two examples are below.

Going on from there, I set up my app and started some simple routes. For those who have used the Sinatra Ruby framework or have used basic node/express routing, this syntax should come quickly. The following route returns a simple json object with the key of “route” and the value of “/”. We use the jsonify method from the flask package to properly format the object. Our application will error out if we neglect to do so.

You can also use dynamic routing with Flask using the <> syntax. In this example, I made an array of projects that would be used in my portfolio and pulled the object data from the specified project using the url.

All in all, I’m still very new to Flask, and it will be an exciting journey to continue to learn the framework and continue on into larger python frameworks such as Django. Python was my first programming language, and it feels good to return there. I look forward to the learning ahead!

Further Reading

Web Developer Focused On Human Connection \\ https://www.linkedin.com/in/john-souza-91001519a/