404 Requested URL not found

hey, gays!
I wrote a URL, but the URL could not be found.The service managed by systemctl.

here is code:

# url 
service.api_bp.add_route(service.Scripts.as_view(), "/scripts")
# this url can't found.
service.api_bp.add_route(service.RunScripts.as_view(), "/scripts/<filename:str>")

# class view
class RunScripts(HTTPMethodView):
    """
    run python script.
    """
    async def get(self, request: Request, filename: str) -> HTTPResponse:
        """
        run python script.
        :param request: Request
        :param filename: str, python scripts name. em alice.py
        :return:HTTPResponse
        """
        file = parse.unquote(filename)
        name = file.split(".")[0]
        msg = ""

        try:
            file = __import__(name)
            assert hasattr(file, "main"), "The scripts no main function"
            msg = file.main()
        except Exception as e:
            msg = e
        finally:
            sys.modules.pop(name)
            del file
            return json(msg)

result

[root@localhost azkaban]# curl http://127.0.0.1:8000/api/scripts/IsAlivedEq1ContentEqNone.py
<!DOCTYPE html><html lang=en><meta charset=UTF-8><title>⚠️ 404 — Not Found</title>
<style>
        html { font-family: sans-serif }
        h2 { color: #888; }
        .tb-wrapper p { margin: 0 }
        .frame-border { margin: 1rem }
        .frame-line > * { padding: 0.3rem 0.6rem }
        .frame-line { margin-bottom: 0.3rem }
        .frame-code { font-size: 16px; padding-left: 4ch }
        .tb-wrapper { border: 1px solid #eee }
        .tb-header { background: #eee; padding: 0.3rem; font-weight: bold }
        .frame-descriptor { background: #e2eafb; font-size: 14px }
    </style>
<h1>⚠️ 404 — Not Found</h1><p>Requested URL /api/scripts/IsAlivedEq1ContentEqNone.py not found

Maybe your blueprint is not attached properly? Here is a simplification of your app that works as expected:

from sanic import Request, Sanic, text
from sanic.blueprints import Blueprint
from sanic.views import HTTPMethodView

app = Sanic(__name__)
api_bp = Blueprint("API", url_prefix="/api")


class RunScripts(HTTPMethodView):
    async def get(self, request: Request, filename: str):
        return text(filename)


class Scripts(HTTPMethodView):
    async def get(self, request: Request):
        return text("Scripts")


api_bp.add_route(Scripts.as_view(), "/scripts")
api_bp.add_route(RunScripts.as_view(), "/scripts/<filename:str>")
app.blueprint(api_bp)

Perhaps you should start from the simplest pattern and work up.

I feel like I should also make a point to say that your endpoint is very insecure. You are allowing the server to execute arbitrary Python scripts with no validation. Be careful with this.