‹ go back

CS50: Web Track.

Published 09 August 2020 at Yours, Kewbish. Also published on Dev.to. 711 words. Subscribe via RSS.


This post is unlisted and has been archived. This doesn't represent my best work; please check out the posts listed here instead.

Introduction

This post is going to be shorter than normal. I may or may not have forgotten to take proper notes for most of this track except Flask.1

Web track, check. Homepage and Finance were pretty fun, and now, we have the final project ahead. This week (or track, I suppose) went through web technologies, going through HTML / CSS / JS and Flask. I’ve been planning on learning Flask for a while2, and this was a great opportunity to try to use it! I know I said that Week 5 was the week I’d been looking forward to the most, but it was genuinely really nice this week to finally work on something I have experience with.

Notes

  • Each machine has an IP
    • used to use IPv4 -> 32 bit addresses
    • now IPv6 -> 128 bit addresses
    • IPv4 overflowed (too many devices)
  • HTTP -> protocol to transfer information
    • HyperText Transfer Protocol
  • DNS -> maps domain numbers to servers that can resolve that domain
  • Response codes -> return of request
  • Flask -> microframework to make web apps w/ Python
  • Flask templates -> render_template()
    • allows us to interpolate variables, extend layouts
  • Flask templating uses Jinja syntax
    • Like Vue mustache syntax, but with % signs
    • specific end blocks for for and if
  • request.args.get() is useful for getting form inputs
    • remember to sanitize input and make sure that inputs exist
      • otherwise, return error
  • In Finance, we make separate conditions to return different templates if post/get
  • use Flask sessions to maintain data like user cookies, etc.
    • otherwise, use the sqlite database
      • run queries with db.execute

Problems

I did Finance first, because I thought that I wanted to redesign my own site for Homepage (more about that later). I found their todo-list structure of teaching / explaining what to do. This was actually one of the reasons I quit Under the GUI (coding extracurricular I was doing when I was a smol child) - too much spoon feeding and not enough self-research.

Giving freedom to implement however we liked was a good idea in terms of implementation and research, but this comes at the cost of testing. (Or maybe this just wasn’t in the CS50 check50 library and they didn’t want to add a bunch of overhead for one problem set check) This might have been an interesting opportunity to explain TDD (hmm, another thing that I should learn) or even just explaining what automated testing was.

When I decided it was finally time to try to attempt redesigning my website, I quickly realized that it’d take ages, especially since I don’t have any ideas right now. The requirements were a 4-page website, so I just slapped an extra page (that looks nothing like the rest of my site because it’s entirely built with Bootstrap) onto my current site. For the JS requirement, I worked in one of those console header things; y’know, console.log()s in most big sites that remind you to apply for their jobs.

It’s pretty simple, but I was feeling tired. Which is another discussion point - I think Homepage was probably the only big problem in CS50 where I didn’t really feel challenged, besides the Python ones. Even with the Python ones I was trying to time myself in a self-run programming contest, whereas here I was just trying to speedrun. Despite this week’s relative apathy, I have a scheme for the final project. (Which will also probably take a while, so we’ll have some filler content in between.)

Conclusion

I can’t believe I’m already almost through with CS50 - as of writing this, I think it’s only been a month and a couple days. I’m surprised how much I managed to speedrun, and how much I managed to learn in the meantime. It’s been an great time3, and I might consider doing the Web Programming course as well. (Or maybe not. We’ll see.) Time to start brainstorming for a final project (I have too many ideas and I have a feeling I’m going to go with none of the above) - hopefully it’ll turn out interesting.


  1. Is it extremely Canadian of me to want to apologize? ↩︎

  2. Why do I always feel the need to go with the quirkiest framework possible? ↩︎

  3. And other phrases I’ve directly copied from my GCI experience post. ↩︎


‹ go back