Author: Miguel Grinberg

2020-07-08T11:41:50Z

Handling File Uploads With Flask

A common feature in web applications is to let users upload files to the server. The HTTP protocol documents the mechanism for a client to upload a file in RFC 1867, and our favorite web framework Flask fully supports it, but there are many implementation details that fall outside of the formal specification that are unclear for many developers. Things such as where to store uploaded files, how to use them afterwards, or how to protect the server against malicious file uploads generate a lot of confusion and uncertainty.

In this article I'm going to show you how to implement a robust file upload feature for your Flask server that is compatible with the standard file upload support in your web browser as well as the cool JavaScript-based upload widgets:

Basic file upload form

2020-06-29T17:00:56Z

Access Localhost From Your Phone Or From Anywhere In The World

Sometimes it is useful to quickly access your Flask application running on localhost from another device or location for testing purposes. In this article I'll show you how to use the pyngrok package to provision a temporary public URL for your application that works from your phone or from anywhere in the world!

2 comments

2020-06-05T10:53:34Z

Introduction to JavaScript Arrow Functions

After I published the tutorial on JavaScript Promises, several people told me that they did not know the new arrow function syntax introduced in the ES6 version of the language.

In this article I'll give you an overview of this syntax, along with information on what platforms support it and how to use them even in older platforms.

2020-05-29T22:13:32Z

Video: Using Trailing Commas in Python

In this short video I comment on the benefits of using "trailing commas" when defining data structures in Python.

2020-05-20T15:41:28Z

Introduction to JavaScript Promises

The use of callback functions is so common in JavaScript that often you find that in the callback from one asynchronous operation the only option that you have is to start another. In many cases you end up having a long chain of callbacks within callbacks, a situation that has been appropriately referenced as callback hell.

Modern JavaScript has introduced the concept of Promises to better deal with asynchronous notifications and prevent callback hell. In this article I'm going to show how to work with libraries based on promises, how to use promises in your own functions, and how to upgrade callback-based functions to promises.

4 comments

2020-05-12T14:28:01Z

Video: Introduction to Terminal Multiplexing with Tmux

Posted by Miguel Grinberg under Programming.

In this video I demonstrate how I used tmux alongisde vim.

Download my .tmux.conf file if you want something to start experimenting with tmux!

1 comment

2020-05-07T18:00:47Z

Video: Setting Up Vim to Work with Python Applications

In this short video tutorial I demonstrate my Vim editor setup for working with Python applications.

Do you want to try this out? Download my .vimrc file! If your tagbar does not work, install Exuberant Ctags (use brew install ctags or sudo apt-get install ctags, or download from http://ctags.sourceforge.net/)

9 comments

2020-04-09T17:03:54Z

How To Add Flask-Migrate To An Existing Project

A question that I frequently get is how to start tracking database migrations with my Flask-Migrate extension when the project has an established database, making it impossible to delete everything and start over from scratch. In this article and companion video I'm going to show you how to set up Flask-Migrate with zero risk for your current database.

19 comments

2020-03-29T11:22:17Z

How to Deploy a React + Flask Project

Welcome to the second part of my "React + Flask" series. In this episode we are going to deploy our project on a production server!

Have you missed the first part of this tutorial? You can find it here.

44 comments

2020-02-21T11:06:26Z

How To Create a React + Flask Project

One of the questions I get asked more often lately is how to create a project that combines a React frontend with a Flask backend. Instead of giving vague answers I decided to write a tutorial about it, including a video in which I go through the steps to create a simple but fully functional React+Flask project.

67 comments