Python: 4. Create the service
This documentation is part of the Automate with the CLI guide. You can view the complete guide here: Start Python, retrieve its credentials, and modify its configuration programmatically using the Stackhero CLI.
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use Python cloud solution designed to simplify your deployments:
- Deploy your application to production within seconds using a simple
git push.- Use your own domain name, with automatic HTTPS certificate setup for secure connections managed on your behalf.
- Take advantage of automatic backups, one-click updates, and predictable pricing, so you can focus on your code rather than infrastructure management.
- Benefit from high performance and security on a private, dedicated infrastructure. Your environment is isolated and protected.
Save time and streamline your workflow: your code can be up and running with Stackhero's Python cloud hosting in just 5 minutes.
Below is an example script that creates a stack, adds your Python service to it, waits for it to start, retrieves its configuration (including generated credentials), and then applies a new configuration.
#!/bin/bash
set -e
export STACKHERO_TOKEN="usr-xxxxxx:your-token"
serviceStore="python" # The Python service store name (see step 2)
instance="..." # An instance size from step 3
region="europe" # A region name from step 3
# Create a stack for your service (uses your default organisation; add --organization if needed)
stackId=$(stackhero --format=script stack-create \
--name="My Python stack")
echo "Stack created: ${stackId}"
# Add Python to the stack (names are resolved automatically)
serviceId=$(stackhero --format=script service-add \
--stack="My Python stack" \
--service-store="${serviceStore}" \
--instance="${instance}" \
--region="${region}")
echo "Service added: python"
# Wait for the service to be fully operational (this may take a few minutes)
stackhero service-wait-for --service="python"
# Retrieve the service configuration, including generated credentials
stackhero service-configuration-get --service="python" --format=json