Flask

What is Flask ?

Flask Vs Django

Stack Overflow Questions Flask vs. Django

Installing Flask

$ python -m pip --version
pip install -U Flask

Now Let’s Check a Simple Flask App

from flask import Flask
app = Flask(__name__)


@app.route('/')
def hello_world():
return 'Hello World'

if __name__ == '__main__':
app.run()
  1. First we imported the Flask
  2. Create app, that hosts the application
  3. Then you need a route that calls a Python function. A route maps what you type in the browser (the url) to a Python function
  4. The function should return something to the web browser,
  5. (app.run()) This is Python for “if this script is run directly then start the application”.

Command Line

$ env FLASK_APP=hello.py flask run
* Serving Flask app "hello"
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Hey !! That’s it You have executed your first Flask Program

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How not to make the Microservices-based project a Mess: Practical Guide

Depicting how project management lost between lot of Microservices

Top Software Trends in 2019

Kubernetes Hands-on Workshop

Day 31 — Flop

An interesting tool/tech I encountered in preparation for boot camp

The difficult road of keeping notes

Sugui Digest. SE01EP13 — Daydreaming

Fun with Multi-stage Dockerfiles

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akash Varun

Akash Varun

More from Medium

Flask ImportError: No Module Named Flask in visual Studio Code Solution

Receive camera picture from user in Django

Nuxt 3 and Django RestFramework works in Docker