How to prevent Flask redirecting to the default port of 5000?

11,163

Check config.py file, you have a route there with 5000 port

Share:
11,163

Related videos on Youtube

Emre Sevinç
Author by

Emre Sevinç

Co-founder & CTO @ TM Data ICT Solutions: helping our clients with data strategy & implementation, enabled by Machine Learning, Data Science & Analytics, AI, Cloud Computing, data engineering, and data quality. For more details, see LinkedIn, GitHub, Twitter, and my blog. I started programming on 8-bit computers in 1980s, and I've been using GNU/Linux since 1994. I've been getting things done in Python, Bash, Java, AWS, Azure, Hadoop, Spark, Common Lisp, Emacs Lisp, etc. I'm also interested in Haskell & Idris. Academic background: mathematics, engineering, and cognitive science.

Updated on June 04, 2022

Comments

  • Emre Sevinç
    Emre Sevinç almost 2 years

    I'm trying to run a Python sample for using Microsoft Graph. It uses Flask libraries for a mini-application that can be run using the Flask's standalone web server.

    I've modified the application initialization line as

    APP.run(port=9999)
    

    And it starts running successfully at http://localhost:9999/, but then after a step, it redirects to http://localhost:5000 which is problematic.

    If I change the initial part of the URL in my browser to http://localhost:9999 and hit ENTER, it continues to function as expected.

    How can tell Flask to "redirect to the URL with the port number I declared in APP.run"?

    • Vivek Kalyanarangan
      Vivek Kalyanarangan about 6 years
      thats weird. Can you show the initialization of the APP object? Also how are you running it?
    • Emre Sevinç
      Emre Sevinç about 6 years
    • Sudheesh Singanamalla
      Sudheesh Singanamalla about 6 years
      After authentication where does the redirect callback return on the flask app? Did you configure graph to redirect on success to localhost:5000/login/authorized instead of :9999/login/authorized?
    • Emre Sevinç
      Emre Sevinç about 6 years
      So, this should be configured on Microsoft Graph side? Not only a Pyhton code configuration issue you mean?
    • Sudheesh Singanamalla
      Sudheesh Singanamalla about 6 years
      You need to configure the REDIRECT_URI on python side and on the Microsoft Graph settings for your application
    • Emre Sevinç
      Emre Sevinç about 6 years
      Indeed! One more thing learned about Microsoft Graph API :) Thanks!
    • Emre Sevinç
      Emre Sevinç about 6 years
      What's that with 3 Close Votes? This is certainly about programming. I'm referring to some Python code, and the answers include a change to that Python code, together with other changes in the comments. Why this is marked as off-topic, is a mystery to me! :(
  • Emre Sevinç
    Emre Sevinç about 6 years
    Changed that to 9999 and then I got from Microsoft side: "Sign in Sorry, but we’re having trouble signing you in. AADSTS50011: The reply address 'localhost:9999/login/authorized' does not match the reply addresses configured for the application: '9eea536f-ccdf-4472-94d8-7ca6acfea142'. More details: not specified"
  • akrn
    akrn about 6 years
    You should configure your Microsoft Graph app to allow new redirect URL
  • Emre Sevinç
    Emre Sevinç about 6 years
    OK, I had to go to apps.dev.microsoft.com/#/application and change Redirect URLs to localhost:9999/login/authorized . I'll accept your answer.