Building Your Own Python Web Framework
Learn how to build your own Python web framework!
"Don't reinvent the wheel" is a common programming mantra we hear nearly every day. But what if you want to learn more about the wheel? What if you want to learn how to make the damn wheel itself so you can make the next iteration better, faster, or stronger? It's often a great idea to reinvent the wheel, especially when it comes to learning -- which is exactly what this course is all about!
In this course, you'll learn how to develop your own Python web framework to see how things work beneath the surface of Flask, Django, and the other Python-based web frameworks. You'll also learn how to build your own Object Relational Mapper (ORM), much like the Django ORM and SQLAlchemy.
Most importantly, you, as a developer, will be building something for other developers, which might be a little different from what you do at your day job and thus you'll learn a lot.
By the end of this course, you'll be able to:
- Explain what WSGI is and why it's needed
- Build a basic web framework and run it with Gunicorn, a WSGI-compatible server
- Develop the core request handlers, routes, and templates
- Implement class-based route handlers
- Test your framework with unit tests and practice test-driven development
- Build a test client to test the API without having to spin up the server
- Implement custom exception handlers to ensure 404 (Not Found) and 500 (Internal Server Error) errors are handled gracefully
- Develop solutions for managing static files and middleware in the framework
- Control allowed methods for your request handlers
- Create a custom response class to make response creation easy
- Create a Python package and upload it to PyPI
- Develop a web application using the framework you built and deploy it to Heroku
- Build your own Object Relational Mapper (ORM)
Tools and Technologies
To get the most out of this course, you should preferably have strong working knowledge of Python 3.
You should also have a solid understanding of the following Internet and web fundamentals:
- IP addresses, URL structures, and DNS
- Web browsers and web servers
- HTTP requests and responses
Review the following videos for more info:
- The Kids Guide to the Internet
- What is the Internet?
- The Internet: IP Addresses & DNS
- The Internet: HTTP & HTML
Finally, it helps to have a bit of experience working with a web framework like Flask, Django, Rails, and/or Express, just to name a few.
- Current version: 2.0.0
- Last updated: March 2nd, 2021
- Author: Jahongir Rahmonov
What will you learn?
In part 1, you'll learn how to write your own web framework using Python, just like Django and Flask. After the main functionality is in place, you'll create a test client and, from that point on, you'll follow basic Test-driven Development (TDD). Once the framework is complete, you'll package it up and upload it to PyPI (the Python Package Index). You'll then develop a small web application with the framework you just built and deploy it to Heroku.
In part 2, you'll build an Object Relational Mapper (ORM) just like the Django ORM and SQLAlchemy. You'll then upload a new version of your framework to PyPy, rewrite the web application you built in the previous part to use your new ORM, and finally upload the new version to Heroku.
Table of Contents
Table of contents from Building Your Own Python Web Framework:
- Requests and Routing
- Duplicate Routes and Class Based Handlers
- Unit Tests and Test Client
- Django-like Routes and Templates
- Exception Handlers and Static Files
- Allowed Methods
- Custom Response Class
- Web App
- Deploying to Heroku
- Database and Table Creation
- Instances and Rows
- Select Queries
- Update and Delete Queries
- PyPI, Web App, Deployment
Get the full course:
Join our mailing list to be notified about course updates and new tutorials.