vscode from user_id url

This commit is contained in:
CakeCN
2025-09-12 17:00:33 +08:00
parent 1e8ec29f3f
commit 33fc4fdc53

View File

@@ -41,7 +41,7 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
caddy_conf = f"""
handle_path /vsc{user_uuid}/* {{
handle_path /vsc{user_id}/* {{
reverse_proxy localhost:{code_server_port}
}}
"""
@@ -65,7 +65,7 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
lines.insert(insert_position, caddy_conf)
with open(caddy_config_path, "w") as f:
f.writelines(lines)
try:
subprocess.run(["sudo", "caddy", "reload", "--config", "/etc/caddy/Caddyfile"])
except subprocess.CalledProcessError as e:
@@ -77,6 +77,7 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
config_path = os.path.join(path_dir, ".config")
tmpd = {
"user_uuid": session["user_uuid"],
"user_id": user_id,
"course_id": course_id,
"chapter_name": chapter_name,
"lesson_name": lesson_name,
@@ -96,7 +97,7 @@ def desktop(user_uuid, course_id, chapter_name, lesson_name):
)
return render_template(
"desktop.html",
vscode_web_url=current_app.config["VSCODE_WEB_URL"]+f"/vsc{user_uuid}",
vscode_web_url=current_app.config["VSCODE_WEB_URL"]+f"/vsc{user_id}",
user_uuid=session["user_uuid"], course_id=course_id, chapter_name=chapter_name, lesson_name=lesson_name,
workspace_path=path_for_vscode,
)