Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redirect in Python
#6
(Apr-02-2021, 10:41 PM)vj78 Wrote: Yes, I am not using any frameworks. I have 3 different pages. 1)Login Page 2)Check.py 3)Sucess.html
You should use a Framework like a simpler one like Flask to avoid doing a lot of unnecessary stuff to fit stuff together.
In the older day CGI(dead now) was a thing,but after WSGI that now all Framework is build on top on.
So do not use use WSGI directly as Framework like Flask, FastAPI is layer above and has done all the undelaying stuff.

Could use Requests.
import requests

response = requests.get('http://github.com/', allow_redirects=False)
print(response.status_code)  # 301 redirect is a permanent redirect
response.url  # http://github.com, not https so redirect
dest = response.headers['Location']  # https://github.com/ -- the redirect destination
print(dest) 
Output:
301 https://github.com
But Form and redirect all of this and more is build in a light Framework like eg Flask.
from flask import Flask, redirect

app = Flask(__name__)

@app.route('/')
def page():
    return redirect('http://github.com/', code=301)

if __name__ == "__main__":
    app.run()
Reply


Messages In This Thread
Redirect in Python - by vj78 - Apr-02-2021, 10:41 PM
RE: Redirect in Python - by SheeppOSU - Apr-03-2021, 01:52 AM
RE: Redirect in Python - by vj78 - Apr-03-2021, 02:44 AM
RE: Redirect in Python - by SheeppOSU - Apr-03-2021, 05:39 AM
RE: Redirect in Python - by ndc85430 - Apr-03-2021, 06:03 AM
RE: Redirect in Python - by snippsat - Apr-03-2021, 10:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Api request redirect url pietervp 1 1,746 Jul-28-2022, 03:05 PM
Last Post: snippsat
  Redirect uri mismatch github in django SubratP 0 1,642 Oct-04-2021, 05:04 PM
Last Post: SubratP
  redirect to page rwahdan 1 1,780 Aug-16-2021, 10:05 AM
Last Post: Larz60+
  Redirect Url calancathy 2 3,284 Jan-13-2020, 11:54 AM
Last Post: calancathy
  Flask redirect(request.url) returns None iFunKtion 1 10,488 Nov-27-2018, 10:50 PM
Last Post: nilamo
  Django don't redirect to an external url PeppePegasus 0 4,461 Dec-07-2017, 02:25 PM
Last Post: PeppePegasus

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020