Flask is a lightweight Python library for building web applications. Its small footprint makes it approachable when data scientists need a first web interface without extensive web-development background. section 13.1
A basic Flask workflow follows a short, practical sequence:
- Install Flask with pip. section 13.1.1
- Create a central Flask application object and map URL routes to Python functions. section 13.1.1
- Return a message or HTML from each route, then launch the application with python app.py. section 13.1.1
- Expand the prototype into multiple webpages using links, headings, and dashboard routes. section 13.3.1
Minimal Flask application
from flask import Flask app = Flask(__name__) @app.route('/') def main_page(): return "Sample dashboard application" if __name__ == '__main__': app.run() Running python app.py makes the page available locally at http://127.0.0.1:5000. section 13.1.1
Listing 13.2 For this example, we are creating a basic application that shows a message on a webpage.
from flask import Flask #1
app = Flask(__name__) #2
@app.route('/') #3
def main_page(): #4
return "Sample dashboard application" #5
if __name__ == '__main__': #6
app.run() #6
Use the complete starter listing to inspect Flask imports, application creation, route declaration, response text, and application launch. section 13.1.1





