top of page
PD-Logo-Day.png

CS50 Week 9 Flask : I Built a Stock Trading App with Flask and I'm Never Looking at Another Apology Template the Same Way Again

  • Writer: Parsa Dev
    Parsa Dev
  • 2 days ago
  • 2 min read
A modern dark mode stock trading dashboard displaying a portfolio table with AAPL and NFLX tickers, green and red candlestick charts, and a clean fintech UI built with Flask and Python for CS50 Week 9

Week 9 of CS50 throws you straight into the deep end of full-stack web development. The problem set, C$50 Finance, tasks you with building a fully functional stock trading web application from scratch using Python, Flask, SQLite, and Jinja2 templating. You're not just writing a couple of routes and calling it a day — you're handling user authentication, real-time stock price lookups via an external API, session management, and a relational database that tracks every single transaction a user makes. It sounds intimidating, and honestly, it is. But once it clicks, it really clicks.

The trickiest part wasn't the Python logic — it was thinking about data flow. Every feature forces you to ask: where does this data come from, where does it go, and what happens when someone tries to break it? Building the Buy and Sell routes taught me more about SQL aggregation than any lecture ever could. Using SUM(shares) GROUP BY symbol to calculate a live portfolio, recording sales as negative share values, and making sure the index page only shows stocks the user actually still owns — these aren't textbook exercises, they're real engineering decisions with real consequences if you get them wrong.

What I enjoyed most was adding personality to the project. The error handling across the app deliberately catches server-side HTML manipulation with humorous apology messages, input validation runs both client-side and server-side, and extra features like password change, cash deposit, and withdrawal round out the experience into something that actually feels like a product. Flask's simplicity is deceptive — it gives you just enough rope to build something genuinely impressive, or to hang yourself with if you're not careful about duplicate route names and foreign key constraints.

CS50 Week 9 Flask

Comments


bottom of page