How To Setup Flask On My Python Hosting Account.

What is Flask?

Flask is an API of Python that allows us to build up web-applications. Flask's framework is more explicit and easier to learn because it has less base code to implement a simple web-Application.

How Do I Set up Flask?

  1. Before starting the process, take a backup of your app.py file ( this is because Flask uses App.py as against Django that uses wsgi.py) as you will need to replace the content when setup is done.
  2. On your cPanel dashboard, click on Setup Python App and click on Create Application.

 

 

  1. Set the python version to the one compatible with the application you want to host.
  2. Set the application root to the location of your application.

NOTE: Your files cannot be directly under public_html, so it should be in a subfolder e.g /home/user/public_html/myappfiles in your case, this is why we was used: public_html/Flaskapp.

  1. Set the application URL you wish to use when setting up your application.
  2. Set the application startup file to the location of your App.py file, when setting up yours.  E.g: /home/yourusername/public_html/Flaskapp/app.py.
  3. Set the entry point to the name of your application as declared in the App.py file.
  4. Set the passenger log file to the location where you want error logs to be saved.
  5. Click on create.

 

  1. After this is done, go to the App.py file and replace the content with that of the backed-up file (this is because Cpanel overwrites the file in the App.py file to confirm that the app is working and this has to be replaced with the original content for the app to work properly).
  2. Input the full path to your requirement.txt file in the CONFIGURATION FILES option. E.g **home/yourusername/public_html/Flaskapp/requirements.txt** and click on the add button.
  3. After the requirement file is added, click on the RUN PIP INSTALL button and select the file you added to install requirements and dependencies for the application.
  4. Restart the application.

Was this answer helpful? 0 Users Found This Useful (0 Votes)