{"feed":"Envato-Tuts-Code","feedTitle":"Envato Tuts+ Code","feedLink":"/feed/Envato-Tuts-Code","catTitle":"Design","catLink":"/cat/design"}

Python provides several ways to download files from the internet. This can be done over HTTP using the urllib package or the requests library. This tutorial will discuss how to use these libraries to download files from URLs using Python.


The requests library is one of the most popular libraries in Python. Requests allow you to send  HTTP/1.1 requests without the need to manually add query strings to your URLs, or form-encode your POST data.

With the requests library, you can perform a lot of functions including:

  • adding form data,
  • adding multipart files,
  • and accessing the response data of Python

The first you need to do is to install the library and it's as simple as:

To test if the installation has been successful, you can do a very easy test in your  python interpreter by simply typing:

If the installation has been successful, there will be no errors.

HTTP requests include:

  • GET
  • POST
  • PUT
  • HEAD
Making a GET request

Making requests is very easy as illustrated below.

The above command will get the google web page and store the information in thereq variable. We can then go on to get other attributes as well.

For instance, to know if fetching the google web page was successful, we will query the status_code.

What if we want to find out the encoding type of the Google web page?

You might also...

Want to learn how to use a full-featured Python microframework? Try our new course, Build a Web App With the Flask Microframework for Python.

In this two-hour course, instructor Derek Jensen will show you how easy it is to get up and running with the Flask microframework for Python. You'll learn everything you need to know to create a Flask web app from scratch. You'll cover all the basics, starting with scaffolding and moving on to templates, creating and handling forms, and sessions with user login. 

You can take our new course straight away with a subscription to Envato Elements. For a single low monthly fee, you get access not only to this course, but also to our growing library of over 1,000 video courses and industry-leading eBooks on Envato Tuts+. 

Plus you now get unlimited downloads from the huge Envato Elements library of 420,000+ creative assets. Create with unique fonts, photos, graphics and templates, and deliver better projects faster.


Thoroughly testing a website that you have created is just as important as developing it. 

Let's say your company has created an e-commerce website. If you just tested the "Buy Now" button for the electronics category and it worked, you might think that it is working for all other categories as well. What if you later found out that a glitch is preventing the users from clicking on the "Buy Now" button for all products under the fitness category? Something like this is definitely going to put a dent in the revenues of the e-commerce company. It is not just about the revenues either; it also affects the reputation of the company. Users may entirely avoid visiting your website in favor of the competition.

Developers and companies sometimes avoid thoroughly testing their website because of two main constraints: time and money. Even if you have run all possible tests for your website on a single device, there is no guarantee that it will work on every other device as well. There are a lot of factors like browser, operating system, and screen size that need to be taken into account. Moreover, new devices with different screen sizes and capabilities keep popping up. Testing on over a thousand combinations of browsers, operating systems, and screen sizes is also going to be a time-consuming process. As a result, many companies don't test their websites as thoroughly as they should.

CrossBrowserTesting can solve both these problems very elegantly. This service allows you to run automated...

The power of the star.

Not one. Not two. How about five?

That'd be great.

The five-star rating system is one that says so much, so quickly. Browsing movies, products, comments? No matter. A quick glance at a rating is a great way to communicate.

So why not add it to your blog comments, digital downloads, product sales, or media reviews?

You can easily add a WordPress star rating plugin to your website—no matter what you're interested in allowing users to rate.

Dive into these 10 best WordPress star rating plugins and see if you can find your five-star solution.

1. Product Category Rating

Easily boast about your five-star reviews using widgets and shortcodes with the Product Category Rating plugin.

The widget is an easy drag and drop with filters, and shortcodes can easily be configured using the built-in shortcode generator.

"The average rating of the product category is calculated based on each review rating received by the product."

Features also include:

  • custom post type and multisite support
  • support and detailed documentation
  • translation ready
  • and more

Between the easy shortcode generator and built-in widgets, you can easily add WordPress star ratings to your website with the Product Category Rating plugin.

2. Rating Form

If customization is your thing, then look no further for your WordPress star rating plugin—give Rating Form a try.

"Choose or create a Rating Form, choice of Stars, Hearts, Smileys, Thumbs Up & Down and many more or upload your own shapes. Lots of features and still expanding."

Let me start this tutorial by taking some theoretical jargon out of your way. When we talk about image enhancement, this basically means that we want a new version of the image that is more suitable than the original one. 

For instance, when you scan a document, the output image might have a lower quality than the original input image. We thus need a way to improve the quality of output images so they can be visually more expressive for the viewer, and this is where image enhancement comes into play. When we enhance an image, what we are doing is sharpening the image features such as its contrast and edges.

It is important to note that image enhancement does not increase the information content of the image, but rather increases the dynamic range of the chosen features, eventually increasing the image's quality. So here we actually don't know what the output image would look like, but we should be able to tell (subjectively) whether there were any improvements or not, like observing more details in the output image, for instance.

Image enhancement is usually used as a preprocessing step in the fundamental steps involved in digital image processing (i.e. segmentation, representation). There are many techniques for image enhancement, but I will be covering two techniques in this tutorial: image inverse and power law transformation. We'll have a look at how we can implement them in Python. So, let's get started!

Image Inverse

As you might have guessed from the title of this section (which...

Using JavaScript can help you add some wonderful features to your website, but it can also slow the site down and frustrate potential visitors. Discover some easy solutions in our new short course, The Designer’s Guide to JavaScript Optimization.

What You’ll Learn

In this short course geared towards web designers, you'll get a great introduction to the topic of JavaScript optimization. Instructor Craig Campbell will show you some easy-to-implement techniques for making your JavaScript, and thus your websites, run smoothly.

You'll learn about efficient DOM traversal, cleaning up your markup, optimizing animation, and more.

Watch the Introduction
Take the Course

You can take our new course straight away with a subscription to Envato Elements. For a single low monthly fee, you get access not only to this course, but also to our growing library of over 1,000 video courses and industry-leading eBooks on Envato Tuts+. 

Plus you now get unlimited downloads from the huge Envato Elements library of 420,000+ creative assets. Create with unique fonts, photos, graphics and templates, and deliver better projects faster.

If you've ever viewed the core configuration file (wp-config.php) for a WordPress site then you'll probably have noticed a section defining eight WordPress constants relating to security keys and salts:


Note: wp-config.php is located in the root folder of your WordPress installation by default.

These constants contain security keys and salts which are used internally by WordPress to add an additional layer of authentication and to enhance security.

WordPress uses cookies (rather than PHP sessions) to keep track of who is currently logged in. This information is stored in cookies in your browser.

To make sure that authentication details are as secure as possible, unique keys and salts are used to increase the level of cookie encryption. These are recommended to be long strings (typically 64 characters long) of random alphanumeric and symbol characters.

The AUTH_KEY, SECURE_AUTH_KEY, and LOGGED_IN_KEY security key constants were added in WordPress 2.6, which replaced a single all-in-one key first introduced in WordPress 2.5.

NONCE_KEY was added soon after, in WordPress 2.7. Corresponding salts AUTH_SALT, SECURE_AUTH_SALT, LOGGED_IN_SALT, and NONCE_SALT were added along with each security key, but it wasn't until WordPress 3.0 that they were added to wp-config.php.

Before WordPress 3.0, you could optionally add your own salt constant definitions to wp-config.php, otherwise they would be generated by WordPress and stored in the database.

While the four security key constants are required, if you remove the salt constants from...

The quick settings panel needs no introduction to Android users. They use the switches it offers all the time to turn services such as WiFi, Bluetooth, and GPS on and off. Over the years, it has grown and improved so much that there's rarely a need to open the actual Settings app these days.

Until recently, the quick settings panel was locked, and users had to be satisfied with a large, but fixed collection of switches—commonly known as tiles. With the launch of Android Nougat, though, that's no longer the case. Users are now free to add, remove, and rearrange tiles. What's more, as an app developer, you can offer your own custom tiles.

In this quick tip, I'll show you how to use the Quick Settings Tile API to create a custom tile from scratch.


Before you proceed, make sure you have the following:

  • the latest version of Android Studio
  • a phone running Android Nougat or higher 
1. Understanding Tiles

In essence, tiles are just readily accessible switches users can press at any time—even when their devices are locked. Because they can display nothing more than an icon and a label, they can only be used for very specific yet simple actions.

Every tile has a state associated with it. Just like a real-world switch, it can either be in an "on" state or an "off" state. As you might expect, a tile that's on is brighter than one that's off. Although you must manage the state of your tile yourself,...

In the world of CSS, documentation is underused. Since documentation is not visible to the end user, its value is often overlooked by clients. Also, if it’s your first time documenting code, it can be difficult to determine what to document and how to do it most effectively.

Yet documenting CSS can offer a lot to your project: from encouraging better code practices to easing the onboarding of new team members. In this article I will explain the advantages of documenting CSS and share what my team and I at Bitovi consider to be the best practices to make documentation work for you–not the other way around. Let’s dive into it.

1. Set the Ground Rules

It’s hard to get on the documentation bandwagon when it’s not clear to you and your team what to document or how you want it to work. So the first step is to agree on which conventions you’ll use and how you should implement them. You can do this in a live document so everybody on the team can contribute. In this way, as your approach changes or becomes more comprehensive, you can keep it up-to-date. A shared Google doc, a wiki page on your code repo, or (even better) a page on your “living style guide” are all great places for this.

Now let’s looks at the actual “ground rules” that you can include.

2. Explain the Structure of Your Code Base

Understanding how your code is organized allows anybody to jump straight into...

In this video from my course, WordPress Security Top Tips, you'll discover some key steps administrators should take to make their WordPress sites more secure.

Top WordPress Security Tips for Admins

Elsewhere in this course, we covered making logins more secure and adding two-factor authentication. But there are a few more things that we can do as an administrator to protect our site.

Stay Updated

The first thing you want to do is make sure that your WordPress site is always up to date. If you look at the dashboard, you'll see if there's an update for WordPress available. 

WordPress notifies you and makes it easy to update by clicking the link. 

Updating WordPress is so simple; there's no reason that you shouldn't keep your site up to date. 

Back Up WordPress

Beyond keeping your site up to date, you should also run backups of your WordPress site. That way, if someone breaks in, you can restore it to the way it was before the site was compromised. 

Again, there are many different options, and with most web hosts, we will have some sort of utility built in to perform backups. 

If there is no solution for backups on your host, you can always use a plugin. A plugin that I like for this is UpdraftPlus

This plugin offers the ability to back up your WordPress site to Dropbox or Google Drive. This plugin is not...


When building web applications, there is always the possibility of working with forms. Learning to handle them as you work with different tools is very important. In this tutorial, you will see how to handle forms in Vue.js.

Get Started

Create a new Vue project using Vue-CLI. If you do not have Vue-CLI installed on your machine, you can do so by running:

That will install Vue-CLI globally on your machine. You can go ahead to create the project by running:

That will create a new Vue project, using the Webpack template. Navigate to the directory that was created for the project, and install the dependencies.

You will be making use of Bootstrap in this tutorial. Open your index.html file and make it look like this.

Nothing fancy here—just the link element tag for our Bootstrap stylesheet. You will build a simple registration form from scratch, and bind the values entered into the form using v-model. When working with forms in Vue.js, you bind form input values to the Vue instance using the v-model directive.

Input Binding

Let's get started with some simple text input to collect the email address, password, and age of...

This tutorial will give an introduction to SMTP, a Python module used for sending mail. It will also demonstrate how to send different email types like simple text emails, emails with attachments, and emails with HTML content.

Introduction to SMTP

The Simple Mail Transfer Protocol (SMTP) handles sending and routing email between mail servers.

In Python, the smtplib module defines an SMTP client session object that can be used to send mail to any Internet machine with an SMTP or ESMTP listener daemon.

Here is how to create an SMTP object.

Create and Send a Simple Email

The following script will allow you to send an email via the Gmail SMTP server. However, Google will not allow logging in via smtplib because it has flagged this type of login as "less secure". To solve this, go to while you're logged in to your Google account, and "Allow less secure apps". See screenshot below.

We will follow the following steps to accomplish this process:

  • Create an SMTP object for connection to the server.
  • Log in to your account.
  • Define your message headers and login credentials.
  • Create a MIMEMultipart message object and attach the relevant headers to it, i.e. From, To, and Subject.
  • Attach the message to the message MIMEMultipart object.
  • Finally, send the message.

This process is as simple as shown below.

Core ML makes it easy for iOS developers to add deep machine learning to their apps. In this post, I'll show you how you can train a Core ML model to derive intelligent insights.

Machine learning has undoubtedly been one of the hottest topics over the past year, with companies of all kinds trying to make their products more intelligent to improve user experiences and differentiate their offerings. Google invested between $20B and $30B in artificial intelligence just last year alone, according to McKinsey’s State Of Machine Learning And AI, 2017

AI is turning into a race for patents and intellectual property (IP) among the world’s leading tech companies...The report cites many examples of internal development including Amazon’s investments in robotics and speech recognition, and Salesforce on virtual agents and machine learning. BMW, Tesla, and Toyota lead auto manufacturers in their investments in robotics and machine learning for use in driverless cars. Toyota is planning to invest $1B in establishing a new research institute devoted to AI for robotics and driverless vehicles. (source: Forbes)

Apple is no exception to this trend, having utilized Machine Learning in their own apps. For example, the Photos app for iOS can recognize faces, objects and landmarks, and Siri infers intent and meaning from speech. Messages for iOS intelligently suggests and predicts words based on previous user behaviors. 

In this tutorial, you will learn about how to apply machine learning algorithms to a set of training data,...

The material design team at Google simply defines the functionality of tabs in Android as follows:

Tabs make it easy to explore and switch between different views.

In this post you'll learn how to display tabs using the TabLayout and ViewPager API. In this practical tutorial, we'll cover the following:

  • The TabLayout and ViewPager components. 
  • The different tab modes: scrollable and fixed.
  • How to display icons instead of text for the tab titles.
  • For a bonus, you'll also learn how to use the Android Studio templates feature to quickly bootstrap your project with a tabbed interface. 

A sample project for this tutorial can be found on our GitHub repo so you can easily follow along.


To be able to follow this tutorial, you'll need:

You can also learn all the ins and outs of the Kotlin language in my Kotlin From Scratch series.

Introduction to the TabLayout Component

According to the official Android documentation on TabLayout, it says:

TabLayout provides a horizontal layout to display tabs.

The TabLayout component is one of the components introduced as part of the material design artifacts. Moreover, it is also included in the design support library. In a...


Beyond enabling iOS developers to easily store data on the cloud, as well as authenticating users through their robust SDKs, Firebase also provides a convenient storage solution for media. Firebase Storage allows developers to store and retrieve audio, image, and video files on the cloud. That is, Firebase Storage exposes a set of SDKs to give developers the ability to manage their user-generated content assets alongside its sibling product, the Firebase Realtime Database, which stores user text content. 

However, Firebase Storage is more than just a storage container for rich media assets. It assists developers by offering offline synchronization for users and their devices, queuing and resuming images and videos when the user goes off and back online. This works similarly to how Firebase Realtime Database orchestrates synchronization of user data to the back-end.

This tutorial continues from our previous tutorial on Getting Started With Firebase Authentication for iOS, where we looked at how to manage, store and work with users in Firebase.

Objectives of This Tutorial

This tutorial will expose you to the Firebase Storage SDKs, to help you manage your app’s media assets—such as image, audio and video files—storing them remotely on the cloud, and retrieving them throughout your app. In this tutorial, you will learn how to:

  • set up your app for Firebase Storage
  • create and work with storage references 
  • upload media to Firebase Storage
  • download media from Firebase Storage
Assumed Knowledge

This tutorial...

In this article, we're going to explore the Mail API in the Laravel web framework. Laravel takes advantage of the popular SwiftMailer library, which is easy to use and comes with a variety of email drivers to choose from. In the latter stages of the article, we'll go through an in-depth demonstration of the concepts discussed in the first half of the article.

Setting Up the Prerequisites

Laravel implements a wrapper on top of the SwiftMailer library that makes email management very easy to configure and use at the same time. You can find the default mail settings at config/mail.php.

Whether you’re using Instagram for business or pleasure, it’s a great way to make new friends, customers, or fans. Doing the work of getting your account before as many eyes as possible, however, can be time-consuming, and since we all have the same limit to the hours of the day, any tool that saves us time and helps us to use Instagram more efficiently and effectively is bound to be invaluable.

Today, I’m taking a look at the 10 best PHP Instagram scripts and widgets available at CodeCanyon. Some will help you automate routine functions, others help you break through the barrier to downloading images and videos from Instagram, and others still help you do a range of tasks like creating e-postcards from Instagram photos.

Automation Tools1. Nextpost Instagram

Automation tools can save an enormous amount of time, and Nextpost Instagram is just such a time-saver. 

First, it allows you to manage your Instagram account or multiple accounts from a single panel, and secondly you can use it to schedule posts into the future. Nextpost is easy to install and has a mobile responsive design.

2. VTGram

VTGram is another time-saving tool that carries more features than Nextpost. With VTGram, users can auto-post photos, stories and videos on their Instagram account using the schedule feature. You can also use hashtags, locations and/or usernames to find posts you’re interested in and auto-like or leave an auto-comment on those posts with one click.

VTGram also allows you to auto-follow users based on a hashtag they use, their location, or their username. You can auto...


React components encapsulate parts of the UI. Your full React application UI is rendered as a tree of many nested components. Depending on the flow of the applications, individual components need to perform some tasks before and after rendering as well as before and after updating.

Finally, cleanup and error handling is also important. React provides a slew of lifecycle methods that you can override and inject your own logic at the right place. In this tutorial you will learn about the lifecycle of a React component from cradle to grave, what methods are available at each stage, and when it is appropriate to override them.

Note that I use the modern ES6 classes style in this tutorial.

The PopularBar

I will use a component called the PopularBar to illustrate all the lifecycle methods and how they behave. The full source code is available on GitLab.

The popular bar contains two other components called ClickCounter. Each ClickCounter component contains a button with an emoji and displays the number of times it was clicked added to the count property it receives from its host. Here is the render() method of ClickCounter:

With the recent enhancements to Android and iOS, it's now easier than ever to begin developing augmented reality applications. In our new course, Get Started With Augmented Reality for iOS, you will learn to code augmented reality apps for iOS using the ARKit framework. 

Your instructor Markus Mühlberger will show you how to detect flat surfaces in the real world, how to add geometric primitives and models to the AR scene, how to light your scene in a way that matches the ambient conditions, and even how to apply physics to your AR models. 

As if that's not enough, you'll also learn how to create an AR measurement app, to measure the distance between any two points in the real world!

You can take our new course straight away with a subscription to Envato Elements. For a single low monthly fee, you get access not only to this course, but also to our growing library of over 1,000 video courses and industry-leading eBooks on Envato Tuts+. 

Plus you now get unlimited downloads from the huge Envato Elements library of 400,000+ creative assets. Create with unique fonts, photos, graphics and templates, and deliver better projects faster.



Vue.js components are important to understand as you work with Vue.js. In this tutorial we are going to dig into Vue.js components, understanding the basics and applying them to an application. Let's get started.

What Are Components?

Components enable us to break the complexity of an application into tiny chunks. For example, a typical web application will have sections like header, sidebar, content, and footer.

Vue.js allows us to break each of these sections into separate modular code called components. These components can be extended, and then attached to the application you are working on. Components are a great way of reusing your code throughout your application.

Let's say you have a blog application, and you would like to display a list of blog posts. Using a Vue component, you can do:

Vue handles the rest.

Create a simple HTML page that mounts a Vue instance to your DOM element. You will use this to learn about components. Here is what the sample HTML page should look like: