Change Flask Root Folder for Templates and Static Files

Today I was facing a problem, I didn’t know how to change Flask root directory. Flask by default look for templates and static files under the root directory (/), how can we change that? Changing the root path Here’s my directory structure: . ├── api_files │ ├── static │ │ └── style.css │ └── templates │ └── index.html ├── api.py ├── Pipfile └── Pipfile.lock 3 directories, 5 files I want Flask to be able to process the folders static and templates inside the api_files folder, my main Flask app is api....

May 12, 2018 · 1 min · Franccesco Orozco

Deploy a Flask Project to Heroku

I was suddenly in the need of deploying a very basic Flask API to the cloud, so it can be available to the public. The thing is, Flask is not made for a production and scalable environment, but if you only need to deploy a very basic web server to Heroku then this guide is for you. Initialize a repository First of all we will need to set up a virtual enviroment with Pipenv, a Flask app, and initialize a repository....

May 10, 2018 · 3 min · Franccesco Orozco

Create a Basic API With Flask

What is Flask? Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions. Flask is a microframework for Python that you can use to quickly create API’s and websites. It’s a great and easy to use platform, let’s create a simple API, but first we will go through the basics. Flask Installation We’re going to install Flask in our virtual environment to later import it into our code....

April 7, 2018 · 4 min · Franccesco Orozco