Thanks to visit codestin.com
Credit goes to fixed.docs.upsun.com

Platform.sh is now Upsun. Click here to learn more
Upsun Fixed User Documentation

Web servers

Try Upsun for 15 days
After that, enjoy the same game-changing Upsun features for less with the First Project Incentive!¹ A monthly $19 perk!
Activate your 15-day trial
¹Terms and conditions apply. Only for Flexible Resource projects.

The Python ecosystem offers a number of web servers that can be used to deploy to Upsun Fixed. The following examples deploy a Django project named myapp. They assume a myapp/wsgi.py or myapp/asgi.py file with a callable application. Adjust the examples to fit your framework and app.

Gunicorn Anchor to this heading

Gunicorn is a Python WSGI HTTP Server for Unix that operates on a pre-fork worker model. The Gunicorn server is broadly compatible with various web frameworks, light on server resource usage, and fast.

To deploy with Gunicorn on Upsun Fixed , use one of the following examples to update your app configuration.

The examples vary based on both your package manager (Pip, Pipenv, or Poetry) and whether your app listens on a TCP (default) or Unix (for running behind a proxy server) socket. For more information on upstream sockets and protocols, see the application reference.

The snippets below assume that Gunicorn has been added as a dependency to your requirements.txt, Pipfile.lock, or poetry.lock.

.platform.app.yaml
type: 'python:3.13'
web:
  commands:
    start: "gunicorn -w 4 -b localhost:$PORT myapp.wsgi:application"
  locations:
    "/":
      passthru: true
    "/static":
      root: "static"
      expires: 1h
      allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "gunicorn -w 4 -b unix:$SOCKET myapp.wsgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "pipenv run gunicorn -w 4 -b localhost:$PORT myapp.wsgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "pipenv run gunicorn -w 4 -b unix:$SOCKET myapp.wsgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "poetry run gunicorn -w 4 -b localhost:$PORT myapp.wsgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "poetry run gunicorn -w 4 -b unix:$SOCKET myapp.wsgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true

Gunicorn workers Anchor to this heading

These examples define four worker processes with -w 4. For more details on what you can configure, see the Gunicorn documentation.

Workers can also be defined with a custom worker class, such as Uvicorn, gevent, or Tornado.

For example, to add a Uvicorn worker class to the pip example for Unix, adjust the start command to the following:

.platform.app.yaml
web:
    upstream:
        socket_family: unix
    commands:
        start: "gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b unix:$SOCKET myapp.wsgi:application"

Daphne Anchor to this heading

Daphne is a HTTP, HTTP2 ,and WebSocket protocol server for ASGI and ASGI-HTTP, developed to power Django Channels.

To deploy with Daphne on Upsun Fixed , use one of the following examples to update your app configuration.

The examples vary based on both your package manager (Pip, Pipenv, or Poetry) and whether your app listens on a TCP (default) or Unix (for running behind a proxy server) socket. For more information on upstream sockets and protocols, see the application reference.

The snippets below assume that Daphne has been added as a dependency to your requirements.txt, Pipfile.lock, or poetry.lock.

.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "daphne -p $PORT myapp.asgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "daphne -u $SOCKET myapp.asgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "pipenv run daphne -p $PORT myapp.asgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "pipenv run daphne -u $SOCKET myapp.asgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "poetry run daphne -p $PORT myapp.asgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "poetry run -u $SOCKET myapp.asgi:application"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true

Uvicorn Anchor to this heading

Uvicorn is an ASGI web server implementation for Python.

To deploy with Uvicorn on Upsun Fixed , use one of the following examples to update your app configuration.

The examples vary based on both your package manager (Pip, Pipenv, or Poetry) and whether your app listens on a TCP (default) or Unix (for running behind a proxy server) socket. For more information on upstream sockets and protocols, see the application reference.

The snippets below assume that Uvicorn has been added as a dependency to your requirements.txt, Pipfile.lock, or poetry.lock.

.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "uvicorn myapp.asgi:application --port $PORT --workers 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "uvicorn myapp.asgi:application --uds $SOCKET --workers 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "pipenv run uvicorn myapp.asgi:application --port $PORT --workers 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "pipenv run uvicorn myapp.asgi:application --uds $SOCKET --workers 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "poetry run uvicorn myapp.asgi:application --port $PORT --workers 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "poetry run uvicorn myapp.asgi:application --uds $SOCKET --workers 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true

Uvicorn workers Anchor to this heading

These examples define four worker processes with -w 4. For more recommendations on this and other settings, see the Uvicorn documentation.

Instead of the -w flag, you can also use the WEB_CONCURRENCY variable. See how to set variables.

Hypercorn Anchor to this heading

Hypercorn is an ASGI and WSGI web server inspired by Gunicorn.

To deploy with Hypercorn on Upsun Fixed , use one of the following examples to update your app configuration.

The examples vary based on both your package manager (Pip, Pipenv, or Poetry) and whether your app listens on a TCP (default) or Unix (for running behind a proxy server) socket. For more information on upstream sockets and protocols, see the application reference.

The snippets below assume that Hypercorn has been added as a dependency to your requirements.txt, Pipfile.lock, or poetry.lock.

.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "hypercorn myapp.asgi:application -b localhost:$PORT -w 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "hypercorn myapp.asgi:application -b unix:$SOCKET -w 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "pipenv run hypercorn myapp.asgi:application -b localhost:$PORT -w 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "pipenv run hypercorn myapp.asgi:application -b unix:$SOCKET -w 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    commands:
        start: "poetry run hypercorn myapp.asgi:application -b localhost:$PORT -w 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true
.platform.app.yaml
type: 'python:3.13'
web:
    upstream:
        socket_family: unix
    commands:
        start: "poetry run hypercorn myapp.asgi:application -b unix:$SOCKET -w 4"
    locations:
        "/":
            passthru: true
        "/static":
            root: "static"
            expires: 1h
            allow: true

Hypercorn workers Anchor to this heading

These examples define four worker processes with -w 4. For more details on what you can configure, see the Hypercorn documentation.

Workers can also be defined with a custom worker class, such as Asyncio, Uvloop, or Trio.

For example, to add a Asyncio worker class to the pip example for Unix, adjust the start command to the following:

.platform.app.yaml
web:
    upstream:
        socket_family: unix
    commands:
        start: "hypercorn myapp.asgi:application -b unix:$SOCKET -w 4 -k asyncio"