Beginner's Guide: Starting a Flask App from Scratch

Beginner's Guide: Starting a Flask App from Scratch

Have you ever been interested in wanting to get into developing a flask app from scratch in python and don’t know where to go? well you’ve found the right place. Here is a Beginners guide to how to begin your journey in developing web apps or even getting a start in developing web apps using python.

What is Flask?

Flask is a Micro-Framework that is built for python. Since it’s more based around being a “Micro-Framework”, we only need to install the packages that we need for our projects. It has a much easier learning curve for a beginner and it’s faster to get spun up and running to the server.

The Setup: Create your Environment

In python we need to create an environment to install our packages to run the correct framework that we want. Disclaimer: I am running this on macOS.

python3 -m venv [ Env name ]

you should also get a folder that is the name of the environment you’ve created

after that, now we can start the environment and also install the flask package

source venv/bin/activate
(env-name)createdbydalius -> pip install flask

from here we can now create a main.py (or name it whatever you would like)

# main.py

from flask import Flask

def create_app()
    app = Flask(__name__)
    app.secret_key = "secret"

    @app.route("/", methods = ["GET"]
    def home():
        return "welcome to flask"
    return app

if __name__ == "__main__":
    app = create_app()
    app.run(debug=true)

and “tada” we have just started our very first flask app