0% found this document useful (0 votes)
7 views10 pages

Introduction To Flask and Web Development

This document provides an introduction to Flask, a lightweight web framework for Python, and outlines the steps to set up a development environment, create a simple web application, and understand routes and views. Key objectives include building a basic Flask app with two routes and running it locally. The document also highlights the importance of using a virtual environment and suggests next steps for further learning about Docker and containerization.

Uploaded by

jomarroxas10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

Introduction To Flask and Web Development

This document provides an introduction to Flask, a lightweight web framework for Python, and outlines the steps to set up a development environment, create a simple web application, and understand routes and views. Key objectives include building a basic Flask app with two routes and running it locally. The document also highlights the importance of using a virtual environment and suggests next steps for further learning about Docker and containerization.

Uploaded by

jomarroxas10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Introduction to Flask and

Web Development
Building your first web application with Python!
Objectives of this Module:

• Understand what Flask is and why it is used.


• Set up a Flask development environment.
• Create a simple Flask web app.
• Run the app locally on your machine.
• Activity: Build and run a basic Flask application.
What is Flask?

 Definition: Flask is a lightweight web framework for Python.


 Why Use Flask?
• Simple and easy to learn.
• Ideal for small projects and APIs.
• Flexible with extensions for databases, authentication, and more.
Setting Up the Flask Environment

 Requirements:
 Install Python (latest version).
 Install Flask using pip (pip install flask)
 Create a virtual environment (python –m venv venv)
 Activate the environment and install dependencies.
 Tip: Always use a virtual environment to manage dependencies.
Writing Your First Flask App

 Steps to Create a Flask App:


 Create a new Python file (app.py).
 Import Flask.
 Define a basic route (/).
 Run the Flask application.
 Tip: Use debug=True for easier
development.
Running the Flask Application

 Steps:
 Open a terminal and navigate to the project folder.
 Activate the virtual environment.
 Run the script using python app.py.
 Open http://127.0.0.1:5000 in a browser.
 Tip: Use flask run as an alternative command.
Understanding Routes and Views

 What are Routes?


 Routes define URLs for your web
application.
 Example: /about, /contact.
 What are Views?
 Functions that return responses to a
client request.
 Activity Prompt: Add a new route
(/about) to your app.
Activity

 Task: Build a simple Flask web app with two routes:


 / (Home page displaying "Hello, Flask!").
 /about (Displays "This is the About page.").
 Submission: Save your file as YourName_Module1.py and test it locally.
Send to: [email protected]
Summary

 Key Takeaways:
 Flask is a lightweight and flexible web framework.
 Setting up a Flask project requires Python and pip.
 Routes define URLs, and views return responses.
 Running app.run(debug=True) starts a local web server.
 Next Steps: Learn about Docker and containerizing Flask apps in Module 2.
Introduction to Flask and
Web Development
Building your first web application with Python!

You might also like