From ca6f8ca11e8621e02b849a722469e517902219dc Mon Sep 17 00:00:00 2001 From: Jack Hadrill Date: Sat, 27 Aug 2022 18:45:09 +0000 Subject: [PATCH] Update README and supported HTTP methods. --- README.md | 6 +++--- src/containerspawner/__init__.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 60d4759..912c1bc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ services: image: git.jacknet.io/jackhadrill/container-spawner:latest restart: always environment: - CONTAINER_IMAGE: "codercom/code-server:latest" + CONTAINER_IMAGE: "git.jacknet.io/jackhadrill/code-server:latest" CONTAINER_PREFIX: "vscode" CONTAINER_NETWORK: "vscode_backend" CONTAINER_PERSIST: "/home/coder" @@ -36,9 +36,9 @@ $ docker run -d --rm --name ${CONTAINER_PREFIX}-${X-Forwarded-Preferred-User} -v For example, assuming `X-Forwarded-Preferred-User` is `jack`: ```bash -$ export CONTAINER_IMAGE="codercom/code-server:latest" +$ export CONTAINER_IMAGE="git.jacknet.io/jackhadrill/code-server:latest" $ export CONTAINER_PREFIX="vscode" $ export CONTAINER_NETWORK="vscode_backend" $ export CONTAINER_PERSIST="/home/coder" -$ docker run -d --rm --name vscode-jack -v vscode-jack:/home/coder --network vscode_backend codercom/code-server:latest +$ docker run -d --rm --name vscode-jack -v vscode-jack:/home/coder --network vscode_backend git.jacknet.io/jackhadrill/code-server:latest ``` diff --git a/src/containerspawner/__init__.py b/src/containerspawner/__init__.py index e7dd5de..976fbb7 100644 --- a/src/containerspawner/__init__.py +++ b/src/containerspawner/__init__.py @@ -2,12 +2,14 @@ from flask import Flask, make_response, request from containerspawner.state import StateManager +HTTP_METHODS = ["GET", "HEAD", "POST", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH"] + app = Flask(__name__) state = StateManager() -@app.route("/", defaults={"path": ""}) -@app.route("/") +@app.route("/", defaults={"path": ""}, methods=HTTP_METHODS) +@app.route("/", methods=HTTP_METHODS) def default(path): """Catch all endpoint to spawn Docker containers.""" username = request.headers.get("X-Forwarded-Preferred-User")