Skip to content

ChristinaVoss/hello_flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hello Flask

App structure

Screenshot 2022-05-12 at 09 41 49

Key parts

In this very tiny app we encounter the absolutely essential parts to making a Flask application.

First we import the Flask library:

from flask import Flask

We set up our app variable, which is basically our app, to which you configure and add routes/controller and later extensions.

app = Flask(__name__)

Then we set up the controller for a route ('/') for our app:

@app.route('/')
def index():
  return "Hello Flask!"

And that's it! Yes - you could add other small conventions (we will in later demos), but here we have a tiny bit of Python, which renders in a browser.

Setup

If you have not installed Python3, please do.

First create and activate some form of environment to store your dependencies. I like Conda:

$ conda create -n myenv python=3.7

$ conda activate myenv

Or just use Pythons built in environments:

$ python3 -m venv venv

$ . venv/bin/activate

Then install Flask

$ pip install Flask

Run the app

$ flask run

You should now be able to see "Hello Flask!" in your browser window (at http://127.0.0.1:5000)

Resulting browser window

Screenshot 2022-05-12 at 18 15 10

About

A tiny "Hello Flask" app to demonstrate how simple a Flask app can be.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages