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 Python application, click "Create a service" in the top-left corner in your Dashboard and choose Back-end application.
Connect your Git account and choose the repository to deploy.
Like all back-end applications, a Python application must run on a specific cloud server. Choose the location and configuration of this cloud server. You can upgrade it in the future.
Choose your framework in the App customization window.
We use gunicorn to launch Python applications, as it is a reliable, fast and scalable WSGI server. Make sure that the Start command is filled in correctly. Here is the format:
gunicorn <directory>.<filename>:<application instance>
Click Deploy when you've checked all the parameters.
Django creates a wsgi.py file inside your project directory, so for a Django application the start command will be:
Other Python frameworks
If you have a
main.py file in the root directory with the content below, you'll probably use the command
import flask app = flask.Flask(__name__)
You'll see the deployment process in the log. When it's complete, you'll receive a notification. You can also send these notifications to your Slack.
Usually it takes some time to install the cloud server during the first deployment.
First of all, check the deployment log. You'll see the stage where something went wrong.
The most common issues are with the launch 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.
Also, we're here to help, so don't hesitate to ask us about the causes via chat.
DisallowedHost at /Invalid HTTP_HOST
This issue is caused by Django when you didn't set up the host name in
settings.py file. It's a security measure to prevent HTTP Host header attacks.
What you want to do is to update
settings.py file, changing
ALLOWED_HOSTS to something like this:
ALLOWED_HOSTS = ["your.domain.com"]
or you can allow all domains this way if you don't want to use this security measure:
ALLOWED_HOSTS = ["*"]