
Set up a proper Python 3 development environment on Mac using Homebrew, and install Git and virtualenv to isolate dependencies.
Learn how to install MongoDB with Homebrew, start mongod manually, configure mongod with a local config, and use the mongo shell to list databases and exit.
Set up a clean Python 3 development environment on Windows using Chocolatey. Run PowerShell as administrator, install Git, Python 3, and virtualenv, and verify paths for pip.
Introduction to MongoDB
mkdir ~/datamkdir ~/logsudo apt-get install -y mongodb-orgmongod -f mongod.confexited with error number 100. Just delete the mongod.lock by doing rm -fr ~/data/mongod.lock.mongodb.test.insert({name: "Jorge", last_name: "Escobar"})db.test.find()db.test.find({last_name:"Escobar"})db.records.createIndex( { last_name: 1 } )db.test.insert({name: "Juan", last_name: "Escobar", age: 47})db.test.find({last_name:"Escobar"})db.test.insert({name: {first_name: "Ricardo", last_name: "Escobar"}, age: 23})db.test.find({last_name:"Escobar"})db.test.find( { age: { $lt: 40 } } )db.test.find( { name: "Jorge", last_name: "Escobar" } )The factory pattern for Flask applications
>>> from user.models import User >>> user = User(username='jorge', password='test', email='jorge@fromzero.io', first_name='Jorge', last_name='Escobar')db.user.find({'u': 'jorge'}).explain() and explain how indexes are used ("cursor" : "BasicCursor", "nscannedObjects" : 3,)python manage.py shell and update the user and then check db.user.getIndexes()db.user.find({'u': 'jorge'}).explain() and explain how indexes are used ("cursor" : "BtreeCursor u_1", "nscannedObjects" : 1,)Register User
- Implement the form error
- Install py-bcrypt
- Do the user registration with the salted password
- Try regitering with user "jorge" -- you will get a duplicate key error
Unit testing is a piece of code that tests a unit of work, logical unit in the tested system. Your unit tests should be:
- automated - independent - consistent and repeatable - maintainable
- Start a user test file - Make sure to override application.py with `**config_overrides` and add the config_overrides - Build the main tests.py file
- Login function
- Here we use context (the with function), because without the with block,
the assert would fail with an error because request is no longer available
(because you are trying to use it outside of the actual request).
- Create a nav bar with logged in user
- Create a logout function
- Create a profile page
- Add the navbar to templates/user/login and templates/user/register
Check username format with regular expressions
- Be able to edit your profile if you're looking at your own profile
- Check the edit_profile flag on views
- Add the if/then on the profile view
- Create edit form and add bio
- Modify user model's bio length
- Minor validation changes
- Create a UserBaseForm class
- Do a regex for username
- Put email and username to lower case using signals (install blinker first)
- Write a test for edit on profile page
- Explain how to send email via SES
- Create an AWS account
- Create a user on IAM
- Go to IAM/Policies and attach AmazonSESFullAccess to your user
- Install boto3
- Set credentials in ~/.aws/credentials
- Important: No quotes around your values
- `[default]`
`aws_access_key_id = <your access key>`
`aws_secret_access_key = <your secret key>`
- Set region in ~/.aws/config (you can set the region on the upper right nav on SES console)
- `[default]`
- `region=us-east-1
- Create a mail folder on templates
- Create a base for html and text
- Create register email both text and html
- Add email to utilities/common
- We need to generate a confirmation code
- On user.models add email_confirmed and email_configuration
- On user.views add a UUID and store on the database
- We need a view to confirm the email
- Create a confirm route on user.views
- Register a new user and check on mongodb the code
- Hit /confirm/<username>/<code> with a bad username and a good username
- Check on mongodb
- Hit the correct username again, you should get a 404
- Now send the email when user registers
- Create a HOSTNAME on settings.py (explain dev vs prod)
- Change the URLs on the email templates
- Send the email from register views
- We need to skip sending email when running test
- Create a form for it
- Create a view to enter your email and email is sent
- Create a view to enter the new password
- Create a form for it
- Create a view to enter your email and email is sent
- Create a view to enter the new password
- Create a form for it
- Create a view to enter your email and email is sent
- Create a view to enter the new password
Reset Password Tests
- Create a form for it
- Create a view to enter your current password and two repeat passwords
Develop and validate a change password flow by creating a user, logging in, and posting current, new, and confirm passwords with redirects. Then verify login with the updated password.
Implement edit view for imaging. Save to a user folder, generate a time stamp via thumbnail process, and update the profile image in the template.
Configure Amazon S3 to host user-uploaded images, create buckets, set region and permissions, and update the Flask app to upload and serve images from S3.
Create and verify multiple users, establish friend relationships, and explore the relationship model with foreign keys and statuses in MongoDB indexes.
Create a static method on the relationship model to fetch the status between two users, returning friends, pending, approved, or blocked with a single query.
Develop front-end functionality with javascript and jquery to manage user relationships in a Flask app. Customize base templates, implement hover states for friend, block, and unblock actions, and display status.
Learn to build relationship views in Flask by implementing a login required decorator, reverse relationship checks for pending and approved friendships, and an add-friend workflow with profile and edit views.
Continue building relationship views by extending templates and models to support reverse relationships, blocks, and friendship states (pending, approved) in Flask.
Explore building a relationship-focused frontend for user profiles, implementing friend requests, accept/deny flows, blocking, pending and removing friends, with live demonstration across two users.
Develop and validate relationship features by implementing and running unit tests for user friendships, reverse blocks, and profile templates, using fixtures and assertions to verify page elements.
Develop and validate friendship workflows in a Flask app by writing tests for sending and confirming friend requests, unfriending, blocking, and reverse relationships, then verify page state and database counts.
Builds a flask-based dynamic friends sidebar in a user profile by loading approved friends via a relationship filter, rendering them with templates, and wiring pagination and profile links.
Create a paginated friends view in a Flask profile by using endpoints, MongoEngine paginate, and a hyperlink to a dedicated friends page, with an optional email sending control flag.
Build a reusable follow button as a template macro across profiles and pages, refactoring redirects to return to the referring page with refer, and add hover effects via JavaScript.
Add a feed post form to the user profile view by importing the feed post form, rendering it on the profile page with bootstrap styling, and handling proper form submission.
Implement feed views in a Flask app using a feed blueprint, handling get and post with login required, posting messages to user feeds, and processing messages to broadcast to friends.
Develops a feed process message using relationship data to deliver a user's feed with friends' messages and prepares a frontend feed messages module for display.
Learn to build a feed message template by creating a feed messages module, sanitizing text with bleach, linkifying hyperlinks, and rendering human-friendly timestamps.
Explore resizing feed images and thumbnails, rendering them in templates, and uploading via multipart forms in Flask. Learn to store images as a 200px extra-large size and fix UTC timestamps.
Add a UTC millisecond timestamp function returning a lambda, multiply by 1000 for long timestamps, and apply it to post and image dates in the feed.
Add a message type field to posts to support comments and likes, with a comments collection and feed views for rendering and posting comments.
Build a robust like system and clean up comments in a Flask app. Filter comments by type, add parent indexing, and update templates to display and manage likes.
Limit a user's feed to posts from friends by updating the profile messages query, filtering messages by relationship, and testing with different logins.
Enhance the distribute script to skip posting to blocked users by checking each friend's relationship before posting and add tests for feed messages.
Practice automated feed tests for a social feed, including user login, managing friends, posting messages, and verifying blocking and visibility through step-by-step assertions.
Promote continued learning after the course by inviting newsletter sign-ups, sharing a special promotion, and linking the YouTube channel, Twitter, and Facebook for tips that boost your developer toolbox.
This course will teach you some of the advanced development concepts used in the top tech companies today. How do I know this? Because I’ve been leading tech teams in both large enterprise as well as startup companies in New York City for the past 15 years.
Thousands of students have completed my "Professional Python Web Development Using Flask" Udemy Course, which introduced them to the basic concepts of Python and Flask and this course builds on top of that knowledge and takes you to the next step in web application architecture design.
The course goes through the process of building a social web application using Python Flask and the most popular document store database in the market: MongoDB. We will go over modeling best practices, how to build efficient indexes and how to interact with it using the popular MongoEngine ORM.
Step-by-step we will go over the user registration, login and management, the relationship model for users to become friends, and a scalable news feed system using the same architectural design that Twitter and other popular social applications have been using to handle massive amounts of user data.
Additionally we will setup and use Amazon’s AWS cloud infrastructure for this social application, and you will learn how to manage thousands of images using Amazon S3 and best-of-class email distribution using Amazon SES.
At the end of the course students will be challenged with a final project where all the course material will need to be used to complete it. Students that finish the final project will be eligible for special future promotions.
If you already know the basics of Python and Flask and you are interested in advancing your knowledge, this course will go over some of the advanced concepts of web application development, architecture design, database modeling and leveraging cloud infrastructure services.
The course is divided in 7 sections:
The course has more than 13 hours of video tutorials as well as the source code at the end of each lesson, so that you can see exactly what the whole project looks like in each stage.
The course can take anywhere from 10 days to a month to complete based on how much material the student completes daily.
Additionally we’re constantly updating the course, adding contents thanks to the feedback of our students.
Join this course and continue your path to becoming a professional Python backend web developer!