Skip to content

In this course, you’ll use Python to refactor an existing application that was originally built using Node.js. The app, called Just Tech News, is a website where users can post, upvote, and comment on links to news articles. Instead of using Node.js as the back-end language and Handlebars.js as the templating engine, you’ll use Python to create …

Notifications You must be signed in to change notification settings

cjohnson74/Python-NewsFeed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Newsfeed 🗞 🐍

I use Python to refactor an existing application that was originally built using Node.js. The app, called Just Tech News, is a website where users can post, upvote, and comment on links to news articles. Instead of using Node.js as the back-end language and Handlebars.js as the templating engine, I used Python to create the app and the Python Flask framework to create the application’s views.

To View The Tech News Feed Flask Web App On Heroku:

Click the link to the app above and please share some tech links you think are helpful or interesting. I took the initiative and added some beneficial Python related links to the feed!

I Learned How to Do The Following:

  • Build and deploy to the cloud a Flask API with correct project structure and necessary dependencies.

  • Connect the application to an RDBMS database using SQL Alchemy to support the API model.

  • Create a REST API that performs CRUD operations.

  • Set up and configure a local virtual environment for Python Flask.

  • Explain the differences between JavaScript and Python.

  • Add templating to the application to allow for user interactions.

  • Perform basic DevOps and deploy to a cloud infrastructure.

Tools I Used:

  • Python is an interpreted, high-level, open-source, general-purpose programming language that supports procedural, object-oriented, and some functional programming constructs.
  • pip is the default package manager for Python. It is distributed with Python, which means that when you install Python, pip is automatically installed on your computer!
  • Flask is a lightweight web application framework written in Python. It's designed to make getting started quick and easy, with the ability to scale up to complex applications. It has become one of the most popular Python web application frameworks.
  • SQLAlchemy is the Python SQL toolkit and object-relational mapper that gives Python developers the full power and flexibility of SQL. It provides a full suite of well known enterprise-level persistence patterns, designed for efficient and high-performing database access, adapted into a simple and Pythonic domain language.
  • PyMySQL is a pure Python MySQL driver that connects a Python application to a MySQL database.
  • bcrypt is a PyPI library for Python that allows you to hash passwords. Hashing is the process of taking input and using a mathematical formula to chop and mix it up to produce an output of a specific length. Hashing is a one-way function, meaning that it can easily convert input to a fixed-size output, but it is difficult to invert, or convert in the opposite direction. This attribute allows developers to secure passwords when authenticating users for their applications.
  • python-dotenv is a PyPI dotenv package used to manage environment variables inside Python's native virtual environment, or venv. This virtual environment is a self-contained directory that can maintain its own version of Python as well as its own library dependencies so that multiple Python projects can reside on the same machine without interfering with each other.
  • Gunicorn, or Green Unicorn, is a Python HTTP Server for UNIX that is broadly compatible with various web frameworks (including Python and Flask), simply implemented, light on server resources, and fast.

So why did I use Python when the same app can be built with Node?

Python is one of the most widely used high-level programming languages, with the TIOBE index naming it the second most popular language out of 100 in 2020. It's an interpreted, high-level, open-source, general-purpose programming language that supports procedural, object-oriented, and some functional programming constructs. Created by Guido van Rossum between 1985 and 1990, Python is currently used in such fields as web development, data science, and DevOps.

Python has seen an increase in popularity with the rise of big data—in which extremely large datasets are analyzed computationally to reveal patterns, trends, and associations, especially relating to human behavior and interactions. Python can help us mine big data much faster than any other programming language because it can handle any data type.

Python can also be easily integrated into web applications that need to implement machine learning. Machine learning is a quickly growing branch of artificial intelligence that's based on the idea that systems can learn from data, identify patterns, and make decisions with minimal human intervention.

Just like most other popular programming languages, Python has several frameworks that can make it easier to use. The two most popular Python frameworks are Flask and Django. You’ll use Flask in this course, but you can adapt the same concepts to a Django application.

To complete the refactoring, I connected the Just Tech News application to a relational database using SQLAlchemy, provide user authentication using Flask’s built-in session functionality, and deploy my app to the cloud using Heroku.

Reflection

Looking back at this Tech News Feed project as a whole, I accomplished the following:

  • Set up a virtual environment for Python by using the venv module.
  • Defined functions and classes by using Python syntax.
  • Created and imported Python packages and modules.
  • Used the Flask library to create GET, POST, PUT, and DELETE routes.
  • Created MySQL tables by using the SQLAlchemy ORM.
  • Queried a database by using SQLAlchemy methods.
  • Handled errors by using assert and try...except statements.
  • Used the contextual g and session objects of Flask across routes.
  • Imported custom filter functions into Jinja templates.
  • Created custom decorator functions.

Python vs JavaScript

Along the way, I uncovered many differences and similarities between Python and JavaScript. I have noticed that the differences are mostly syntactical? Concepts like servers, requests, templates, models, conditionals, and errors remain the same across different languages. Since I understand those concepts, I can learn any new programming language, I just have to identify a specific feature that I want to build using that language, and search online for resources that can guide me through the process.

When I learn a new language, PRACTICE is crucial! To practice Python, I can build another Flask web app form scratch or look into uses like scripting or software development. Whatever I choose, now I am equipped to tackle any potential obstacles.

About

In this course, you’ll use Python to refactor an existing application that was originally built using Node.js. The app, called Just Tech News, is a website where users can post, upvote, and comment on links to news articles. Instead of using Node.js as the back-end language and Handlebars.js as the templating engine, you’ll use Python to create …

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published