CS DIY 101
WallyDescription
A simple blog framework following Flask's official tutorial
Pre-Reading
These are optional reading, you can skip them if you already know these topics. Alternatively, you can skip them and come back to it when you encountered them in the project.
HTML
- HTML Tutorial: https://www.w3schools.com/html/default.asp
- HTML Form: https://www.w3schools.com/html/html_forms.asp
Python
- Official Python Tutorial: https://docs.python.org/3/tutorial/index.html, this is more compact and efficient if you already know a few programming languages
- (Alternative) Introducing Python, 2nd ed (free register with OSU): https://www.oreilly.com/library/view/introducing-python-2nd/9781492051374/, this is more gradual but more friendly to beginners
- (Alternative) Learn Python the Hard Way: https://learnpythonthehardway.org/. I personally like this book before it ask you to write actual Python files instead of using the Python REPL. This shows you how a Python program file gets run. Especially I've seen some people having trouble running a .py file despite finishing a Python tutorial.
Git
- Simple Git Tutorial: https://www.liaoxuefeng.com/wiki/896043488029600
- Official Git Book (good if you want to dive a little deeper): https://git-scm.com/book/en/v2
- I recommend putting your project in a Git repo all the time, commit after each chapter, and you can try rollback/forward along with the record. And once you're done, you can put everything on GitHub along with added README and additional features you'd add in the future.
SQL (SQLite)
- Knowing SQL is optional for this project, you can borrow the SQL queries from the tutorial at first. But this is needed if you want to add some additional features (see Addition Exercise)
- https://www.sqlitetutorial.net/
Blog Framework Project
- Flask Project Website: https://flask.palletsprojects.com/en/2.3.x/
- Installation: https://flask.palletsprojects.com/en/2.3.x/installation/
- Actual Tutorial to follow: https://flask.palletsprojects.com/en/2.3.x/tutorial/
- You might need some help understanding HTTP: https://www.tutorialspoint.com/http/index.htm. Such as GET/POST, forms, etc.
- Flask reference Doc whenever you run into something you don't understand: https://flask.palletsprojects.com/en/2.3.x/api/
- Jinja2 HTML template reference: https://jinja.palletsprojects.com/en/3.1.x/templates/
Notes:
- While following the Tutorial, do not copy-paste the code, instead type everything yourself. This will help you notice every detail. (The only exception I'll make is the CSS files, it's not necessary to understand this project).
- When running into problems, try to read the error (if there is), re-read the Tutorial, compare your code with the sample, look at the reference docs (linked above), Google search. Troubleshoot at least an hour before asking someone else (that includes AI tools). This way you can develop your troubleshooting skills.
- If you do need to ask questions, read https://github.com/selfteaching/How-To-Ask-Questions-The-Smart-Way/blob/master/How-To-Ask-Questions-The-Smart-Way.md first.
Additional Exercises
These are not list by order, you can pick whichever interests you. The goal is to allow you improve your skill by expanding the existing codebase. Remember, keep your project in Git versions so it's easy to revert changes if you messed up.
NOTE: remember to update your tests whenever you made changes to the framework
Upload your project to GitHub and add a README.md file
- Create an account at Github.com if don't have one yet (this is probably one of the most important thing in your programming career).
- Write a README.md file using Markdown, see tutorial: https://www.markdowntutorial.com/ or cheatsheet: https://www.markdownguide.org/cheat-sheet/
- Example of a good README.md: https://github.com/doomemacs/doomemacs/blob/master/README.md
- It should have your project name, description, build/install instruction with prerequisite, and potentially screenshot and how to contribute.
- This should be your habit for every project you build in the future
- Type: polishing
- Level: easy
Refactor the Create and Update page into one
- Since Create and Update post page are very similar, try to combine them into one single page.
- Type: refactoring
- Level: medium
Add a Like button and Like count
- Any modern social media has a Like or an equivalent. Try add one.
- Notice: you will need to add an extra <form> in your HTML
- Type: new feature
- Level: medium
Add a user page
- Add a page to display user info (only username for now) and their blogs only
- Type: new feature
- Level: medium
Add a new page for the full blog
- Display only a truncated preview in the index page
- And add a new page to view the full blog
- Type: new feature
- Level: hard
Change your blog's style with CSS
- Read CSS tutorial if you haven't learned CSS before: https://www.w3schools.com/css/default.asp
- Give your blog some new style (color, layout, etc.).
- Don't spend too much time on this one, unless you really like CSS.
- Type: expanding
- Level: easy
Deploy your project to a production server
- Using a public VPS (e.g. https://www.vultr.com/products/cloud-compute/, https://www.vultr.com/products/cloud-compute/). It's not free, but having a private server is very useful throughout your programming career.
- You can also use cloud providers such as AWS/Azure/GCP if you have student discount or trial period. Notice they can be very expensive.
- You can use waitress from the tutorial: https://flask.palletsprojects.com/en/3.0.x/tutorial/deploy/.
- But to deploy as a production website it needs to run as port 80, you would need nginx/Appache httpd to create a proxy server: https://flask.palletsprojects.com/en/3.0.x/deploying/. This step could be optional.
- Type: expanding
- Level: hard if you don't much Linux server experience, otherwise this would be an easy one.
Build a new website! Now that you know how to use Flask
- What else could you make? A shopping website? An image sharing (think Instagram)? An online messaging?
- You can use the quickstart to remind you if you forgot anything: https://flask.palletsprojects.com/en/2.3.x/quickstart/
- Use the API: https://flask.palletsprojects.com/en/2.3.x/api/ and the rest of the Flask documentation to guide you to use and learn new things: https://flask.palletsprojects.com/en/2.3.x/
- Type: exploring
- Level: easy-hard depending what you want to build :)
Further Reading
These could be considered next steps if you are interested in expanding the project further:
HTML & CSS
- So far you might only learned the basic of HTML and CSS with snippet, this is a good book if you'd like to expand your knowledge and add some extra elements to your blog.
- https://learning.oreilly.com/library/view/head-first-html/9781449324469/
Bootstrap
- https://getbootstrap.com/ bootstrap is a useful library to give your website some cool looks.
JavaScript
- Head First HTML5 (free register with OSU): https://www.oreilly.com/library/view/head-first-html5/9781449314712/
- Once you learned JavaScript you could make your website more interactive (more buttons, some drop-down effect, etc.)