Flask is a python web framework.
We can create the web application, Rest API using Flask.
So let's see the minimal steps and minimal line of code to run a flask app
Pre Request: Python and pip should be installed
Follow the below steps:-
Step 1) pip install virtualenv // To install virtualenv globly
Step 2) virtualenv venv // To create virtual environment
Step 3) source ./venv/Scripts/activate // To activate virtual environment
Step 4) pip install Flask // To install Flask in the virtual environment
Step 5) Create app.py file and copy pest below the minimal code of the Flask app
from flask import Flask, escape, request
app = Flask(__name__)
@app.route('/')
def hello():
name = request.args.get("name", "World")
return f'Hello, {escape(name)}!'
Step 6) flask run // To Run Flask App
0 Comments