Having trouble starting server programmatically with Python

Currently I am executing appium server -pa /wd/hub --allow-cors in command prompt and then call my Test app class

class TestApp:
    @log
    def __init__(self,device_name: str = DEVICE_NAME, environment: str = DEFAULT_ENVIRONMENT) -> None:
        environments = {"Staging": ".staging", "Production":"", "Dev":".dev"}
        self._envPackageSuffix = environments.get(environment,environments[DEFAULT_ENVIRONMENT])
        desiredCapabilities = {
            "appium:deviceName": device_name,
            "appium:automationName": AUTOMATION_NAME,
            "appium:platformName": PLATFORM_NAME,
            "appium:platformVersion": ANDROID_VERSION,
            "appium:appPackage": f'{APP_PACKAGE}{self._envPackageSuffix}',
            "appium:appActivity": APP_ACTIVITY,
            "appium:instrumentApp": True,
            "appium:ensureWebviewsHavePages": True,
            "appium:nativeWebScreenshot": True,
            "appium:newCommandTimeout": NEW_COMMAND_TIMEOUT,
            "appium:connectHardwareKeyboard": True,
            "appium:noReset": True,
        }
        options = UiAutomator2Options()
        options.load_capabilities(desiredCapabilities)

        # starting session based on set capabilities
        self._driver = webdriver.Remote("http://localhost:4723/wd/hub", options=options)

        # hard launching the app in case the app fails to launch despite starting session
        self.activate_app()

But now i want to start the server programmatically hence i modified my init as follows:

class TestApp:
    @log
    def __init__(self,device_name: str = DEVICE_NAME, environment: str = DEFAULT_ENVIRONMENT) -> None:
        self.start_server()
        environments = {"Staging": ".staging", "Production":"", "Dev":".dev"}
        self._envPackageSuffix = environments.get(environment,environments[DEFAULT_ENVIRONMENT])
        desiredCapabilities = {
            "appium:deviceName": device_name,
            "appium:automationName": AUTOMATION_NAME,
            "appium:platformName": PLATFORM_NAME,
            "appium:platformVersion": ANDROID_VERSION,
            "appium:appPackage": f'{APP_PACKAGE}{self._envPackageSuffix}',
            "appium:appActivity": APP_ACTIVITY,
            "appium:instrumentApp": True,
            "appium:ensureWebviewsHavePages": True,
            "appium:nativeWebScreenshot": True,
            "appium:newCommandTimeout": NEW_COMMAND_TIMEOUT,
            "appium:connectHardwareKeyboard": True,
            "appium:noReset": True,
        }
        options = UiAutomator2Options()
        options.load_capabilities(desiredCapabilities)

        # starting session based on set capabilities
        self._driver = webdriver.Remote("http://localhost:4723/", options=options) 
        # Note /wd/hub changed to / (because for Appium 2.0 its irrelevant)

        # hard launching the app in case the app fails to launch despite starting session
        self.activate_app()

    def start_server(self):
        self.appium_server =  AppiumService()
        self.appium_server.start(args=['--address', '127.0.0.1', '-p', '4723', '-pa', '/', '--allow-cors'])
        print(self.appium_server.is_running)   # print-> True
        print(self.appium_server.is_listening)  # print-> True

    def __del__(self):
        self.appium_server.stop()

But i am getting the following error when i am trying the second method:

Traceback (most recent call last):
  File "c:\System Test Automation\MobileAutomation\Residential\test.py", line 4, in <module>
    app = TestApp(environment="Staging")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\System Test Automation\MobileAutomation\Residential\Support\Log.py", line 29, in wrapper
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\System Test Automation\MobileAutomation\Residential\TestApp.py", line 78, in __init__
    self._driver = webdriver.Remote(SERVER_URL, options=options)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\System Test Automation\venv\Lib\site-packages\appium\webdriver\webdriver.py", line 229, in __init__
    super().__init__(
  File "C:\System Test Automation\venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 205, in __init__
    self.start_session(capabilities)
  File "C:\System Test Automation\venv\Lib\site-packages\appium\webdriver\webdriver.py", line 318, in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\System Test Automation\venv\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 344, in execute
    self.error_handler.check_response(response)
  File "C:\System Test Automation\venv\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

Test Environment:
Appium-Python-Client 3.0.0
selenium 4.13.0
Device Galaxy S20 FE (real Device)