Adsense Ad

Sunday, 22 March 2020

Flask Python: Basic web app

Before working on FLASK make sure the FLASK is successfully installed with PYCHARM IDE:

You can also use Window Powershell to install FLASK suing following command:
>> pip install Flask

Following is the basic code for developing a web app using FLASK Python:

from flask import Flask, escape, request

app = Flask(__name__)

@app.route('/')
def hello():
    name = request.args.get("name", "World")
    return f'Hello, {escape(name)}!'
@app.route('/hj')
def hj():
    return 'Hello HJ hj'

app.run(debug=True)

@app.route('/')
On web loading, above line route on home page of your app

@app.route('/hj')
Above line route to hj page of your app


No comments: