Rest API with Flask & SQL Alchemy on Godaddy using MySQL as the database.

I have a Godaddy website and decide I wanted to try creating a Flask API connected to a MySQL database. My first order of business was watching this video from Traversy Media REST API With Flask & SQL Alchemy. You can find the code here at Github.

With that I had to setup a Python Application on Godaddy. In order to do this you need to go to your Godaddy cPanel interface. Before you setup the application you will need to create a place to hold the application. I created a sub domain to do this. I called it app.scriptkrewe.info.

You will need this information when you setup your Python app as we will see. Once this is done you can head back to the main cPanel screen and go the the Software section. Click on the Setup Python App link.

Godaddy cPanel Software Section

This will bring you to the Python Web Applications page.

This this page you can view the status of your web applications, stop them, start them, delete them or edit them. We will create one using the Create Application button. Below is what the screen looks like.

Python App Screen

This is where the magic happens. You will need to make some decisions here. The first of which is the version of Python your app needs. Second will be the Application Root. This directory will be created for you with all the files you need in your Home directory. So it will be at the home/username/appdirectory level. After that you will need to pick a site to host your application. This Should be an Empty directory. If you have an index.html or some other file it will pick that up first. Next is your applications start up file. By default Godaddy creates this file in the directory that you named as your Application root and names it app.py. You can change this to what ever you want to work with your application but you will need to modify the passenger_wsgi.py file that is created for you. You will need to identify your app entry point. Usually this is app for app = Flask(__name__). Finally it is a good thing to create a log file. This will be extremely helpful in the log run. I named my file after the application root name.

From here you can Save and Start the app. This will allow you to go to the url of your site and see if python is working.

In my next post we will start the process of putting together the building blocks of the application. See you then.