Extending Python and Flask Web Applications with APIs
Application Programming Interfaces (APIs) can be a great way to programmatically gather or distribute data. API creation really distills down to creating a set of routes that receive requests and return useful data. For example, visiting this page may be easy for a person to read, but it’s harder for a computer program to extract the information it may need. An API can return just the information a program needs.
The site is organized by sections the user can visit to learn about different topics. For this API, we’ll create an endpoint so that when a user pings it with a topic they want to get content resources for, it returns a list of resources.
Before we start coding ...
Build Your Own Smart Auto Response Bot with Python, Flask, Twilio SMS and the CleverBot API
If you are looking for a beginner Twilio project or a new texting buddy, this tutorial is for you! Using the Twilio and CleverBot APIs you will make a Flask app that texts CleverBot, which is an AI you can chat with that learns from its conversations.
You will need a Twilio account with a phone number that can send and receive SMS. In the console navigate to the "Buy a Number" page. Make sure to check off SMS under capabilities and then hit the search button. Any number will do, so feel free to pick one that speaks to you!
You will also need a CleverBot API key. You will have to input payment information to use the API. Luckily, the first month is free! Just remember to cancel your subscription if you don't plan on using it after this project.
Next, you have to ...
High Priced Electricity SMS Alerts with Python and Twilio SMS
As a new homeowner and dad of two toddlers that leave every light in the house on, I recently switched to Commonwealth Edison’s Hourly Pricing Program, which means I shifted the amount I pay for electricity from a fixed price rate to a variable rate.
Most people pay a fixed rate for the price of electricity. In northern Illinois, it’s 7.2 cents per kilowatt hour (kWh), but it’s different for different parts of the country. Many electric companies now offer the option to switch to a variable rate, which is based on the actual real-time market price of energy.
According to ComEd: “These prices vary from hour to hour and day to day according to the actual market price of power. Higher prices are most likely to occur on weekday afternoons during the summer.” Since my wife and I both work, and the kids are at ...
Keeping Track of GitHub Pull Requests with Python and Twilio SMS
If you're working on an urgent project in GitHub with other developers, it's handy to get immediate notifications by SMS. However, there is no SMS option out of the box! So I said, “Enough is enough; I'll start my own notification system!”
In this tutorial, I'll walk you through the steps of building out the beginnings of a notification system for GitHub pull requests. More specifically, we will use the GitHub and Twilio APIs in Python to send texts notifying you when a new pull request has been submitted.
First, we have to set our environment up. This guide was written in Python 3.6. If you haven't already, download Python and Pip. Next we will install
virtualenvto create and activate your virtual environment by entering the followings command in your command-line:
pip3 install virtualenv==15.1.0 python3 -m venv ghpull cd ghpull source ./bin/activate ...
Build an Emojidex with Python and the Twilio WhatsApp API
If you've ever wondered about the story behind your favorite emoji, this app is for you. We'll build an interactive bot to give us more information about just what 💁 is doing. With the Twilio API for WhatsApp and Emojipedia 👌😍 we can easily query this information on demand.
🌅 Getting started
Before we can dig into some code, make sure that your Python and Flask development environment is setup. If you haven't done so already,
- Install Python 3
- Install Ngrok to make your Flask app visible from the internet so Twilio can send requests to it
- Set up your Python development environment
If you're new to Python and Flask check out this handy guide for more information on getting started.
I've started the project off, so clone or download the repo from GitHub and checkout the
git clone -b getting-started email@example.com:robinske/emojimon-whatsapp.git
💬 Setting Up Twilio API ...
Parse HTML for Book quotes with Python, Beautiful Soup, and WhatsApp
My first real paid job was working at the local library in high school. This was perfect because I love reading. With a monthly book stipend company perk and more time to read in my post-grad life, I've started using Goodreads to find new books and to keep track of what I've already read.
This post will go over how to parse the Goodreads quotes page. We'll target popular book quotes and quotes with a specific tag received as input from a WhatsApp message and then send a random quote as an outbound WhatsApp message.
Setting Up Twilio API Sandbox for WhatsApp
At the moment, only approved business accounts can use Twilio's WhatsApp API so we need to use the Twilio API Sandbox for WhatsApp to play around. Let's go on over to the Sandbox in our Twilio console. To activate it we must choose a Sandbox number, agree to ...
Improving your pun game with Python, Rhymebrain and the Twilio API for WhatsApp
Puns are awesome and one easy way to come up with puns is to combine two different words. This is called a portmanteau. Let’s build a WhatsApp bot that gives you portmanteaus for certain words that you message it, so you can come up with better puns on the fly!
To get started make sure you have:
- A Twilio account (sign up for a free Twilio account here)
- The WhatsApp Sandbox Channel.
- Follow these instructions to install the WhatsApp Sandbox Channel in your account.
- You will also need to connect your own WhatsApp account with the sandbox
Like with Twilio Programmable SMS we’ll need a webhook that will respond to incoming HTTP requests with every message ...
Finding and Fixing Website Link Rot with Python, BeautifulSoup and Requests
When hyperlinks go dead by returning 404 or 500 HTTP status codes or redirect to spam websites, that is the awful phenomenon know as “link rot”. Link rot is a widespread problem; in fact, research shows that an average link lasts four years.
In this blog post, we will look at how link rot affects user experience, using Full Stack Python as our example. We’ll build a Python script that detects link rot in Markdown and HTML files so we can quickly find and fix our issues.
A Link Rot Example
The site now has over 145,000 words and 150 pages, including:
- 2400+ links in the repository
- 300+ HTML files
- 150+ Markdown files
And there ...
Building a World Cup Bot with Python, Twilio SMS and Slack
The World Cup. For us Brazilians, it’s like the Super Bowl, NBA Finals, World Series, and Stanley Cup, combined, multiplied by 100.
For those of us diehard ‘futebol’ fans following the games in Russia from the Western hemisphere, it’s been quite the challenge keeping up since most of the games are on while we’re at work.
I knew I wasn’t the only one in the office trying to keep up with the games. To solve this problem I created a bot that combines the Slack API with the Twilio SMS API to provide fans with real-time updates of every exciting moment in every world cup game – fouls, penalties, goals, and all.
This post will walk through how I built it. Feel free to follow these instructions to build your own World Cup bot or a bot for your sport of preference. You can check out the ...
Getting Started with Apache Spark by Analyzing Pwned Passwords
Apache Spark aims to solve the problem of working with large scale distributed data and with access to over 500 million leaked passwords we have a lot of data to dig through. If you spend any time with the password data set, you’ll notice how simple most passwords are. This is why we’re always thinking about how to encourage stronger passwords and recommend turning on Two-factor authentication everywhere it’s available.
While tools like Excel and Python are great for data analysis, Spark helps solve the problem of what to do once the data you’re working with gets too large to fit into the memory of your local computer.
This tutorial will show you how to get setup for running Spark and introduce the tools and code that allow you to do data manipulation and exploration. Read on to find out how to spot the most common ...