OIM3640 - Problem Solving and Software Design

2025 Spring

Session 20 (4/08)

contain

Today's Agenda

  • Welcome/News/Announcements
  • Debugging
  • Introduction to Web Application - Flask

Welcome/News/Announcements

  • Assignments/Project:
    • Assignment 3 (Web App): will be posted next class
    • Project Teaming: anyone not in a team yet?
    • Project Proposal: due 4/12, Saturday
  • Communications
    • Meet with me in person during office hours at least once this semester.
    • Email - specify course # in subject title, e.g., "OIM3640: GitHub settings"
    • Use Slack/GitHub when asking code-related questions
  • Questions?

What we have learned so far...

  • Variables, Expressions, Statements
  • Types: int, float, string, boolean, Nonetype, string, list, dictionary, tuple, set
  • Functions
  • Conditional Statements
  • Iterations
  • Pseudo-code
  • Error Handling
  • APIs and Automation

Debugging

Q&A

  • Questions from exercises, quizzes, assignments.
  • Issues on GitHub
  • Any question today?

Introduction to Web Application - Flask

  • What is Flask?
    • Flask is a micro web framework written in Python, used for building web applications, APIs, and microservices.
  • Flask vs. Django?
    • Flask is simpler and more lightweight, great for small/medium-sized projects.
  • Popular companies/websites using Flask:
    • Built With Flask: Pinterest, Zillow, Twilio, Patreon
    • In Tech Stack: Reddit, LinkedIn, Netflix, Lyft, Airbnb, ...

Flask - Routing

  • What is routing in Flask?
  • How does routing work in Flask?
    • Flask routes are defined using the @app.route() decorator.
    • The decorator is used to associate a URL endpoint with a view function.
    • When a user visits the URL associated with a route, Flask invokes the view function, which generates a response to send back to the user.

Quick Tutorial on Flask

  • Installation
    > python -m pip install flask # Windows users
    > python3 -m pip install flask  # macOS/Linux users
    
  • Creating our first Flask application
    • Create a project/folder, helloflask
    • Create a file named app.py
    • Copy code of "A Minimal Application" from Flask Quickstart
    • Turn on Debug Mode
      if __name__ == "__main__":
          app.run(debug=True)
      

Flask Resources

--- # Improve VS Code Experience - **Appearance** - **Themes**: [VS Code Themes](https://vscodethemes.com/) - **Fonts**: [Coding Fonts](https://coding-fonts.netlify.app/), [142 Programming Fonts](https://www.programmingfonts.org/) - **Extensions**: - **Code Formatting**: - Black Formatter/Ruff, isort, Prettier - **Documentation**: - Markdown All in One, Better Comments, Code Spell Checker - **Fun**: - Power Mode, vscode-faker

--- # Flask Practice - In ***helloflask*** project/folder, add one web page and a route that asks user to enter a location and display the current temperature.