[Python] argparse make python Flask connection failed [closed]

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    I run a server by Python Flask module also use ngrok to connenct another ip address. I wrote a bash script for passing some access tokens and use argparse lib to parse the arguments in my python script.

    #<run.sh>
    TOKEN1="..."
    TOKEN2="..."
    python server.py --access_token "$TOKEN1" --secret_token "$TOKEN2"


    #<server.py>
    parser = argparse.ArgumentParser(...)
    parser.add_argument("--access_token",...)
    parser.add_argument("--secret_token",...)
    args = parser.parse_args() #-->this line
    ...



    the line args = parser.parse_args() cause connection failed, but after remove it, the connection to ngrok become success.

    I don't understand why, does argparse action have conflict with the process?

    Thanks!

    Continue reading...

Compartilhe esta Página