bars icon close icon
magnifying-glass icon

Flask

You can run different types of applications on Python using Hostman: APIs, background workers, cron jobs, private services, and others.

Hostman provides CI/CD for all types of services as well as great scalability.

To deploy a Flask application, follow these steps.

Deployment

Step 1. Create a service

Click Create in the top-left corner of your Dashboard and choose Back-end app.

enter image description here

Step 2. Select the project to deploy

If you are logged in to Hostman with your GitHub, GitLab or Bitbucket account, at this point you will see the repository with your projects, including the private ones.

Choose the project you want to deploy.

If you need to access a different repository, click Connect another repository.

If you didn’t use your Git account credentials to log in, you’ll be able to access the necessary account now, and then select the project.

Step 3. Choose a server

Your Flask application must run on a specific cloud server. Choose the location and configuration of this server. You can upgrade it in the future.

enter image description here

Step 4. Configure the build settings

Next, the App customization window will appear.

enter image description here

The Start command will be filled in automatically.

Make sure that the file name and the module name (app:app) are the same as the ones you’re using. For example, if you have a main.py file in the root directory containing the lines:

import flask app = flask.Flask(__name__)

Then you'll probably use the command:

gunicorn main:app

If necessary, also fill in the Build command. It allows you to customize the build process. You can enter multiple commands separated by &&.

Step 5. Deploy

Click Deploy to start the build process.

Once it starts, you will enter the deployment log. If there are any issues with the code, you will get warning or error messages in the log, specifying the cause of the problem.

The log contains all the debugging data you'll need, but we are also here to help you solve the issues, so do not hesitate to contact us via chat.

Usually it takes some time to install the cloud server during the first deployment.

When the deployment is complete, you will receive an e-mail notification and also see a similar log entry:

enter image description here

All done!

Your project is up and ready.

Troubleshooting

The deployment fails

If the deployment fails, first of all check the deployment log. You'll see the stage where something went wrong.

The most common issues are with the start command. Check that everything is working with gunicorn in your development environment. Check that all the modules your need to launch an application are in the requirements.txt file.