当前位置:网站首页>Page Jump and redirection in flask framework
Page Jump and redirection in flask framework
2022-07-24 03:51:00 【One of IT guys】
Sample code 1:
from flask import Flask, redirect, url_for
app = Flask(__name__)
@app.route('/')
def index():
login_url = url_for('login')
return redirect(login_url)
@app.route('/login')
def login():
return ' This is the landing page '
if __name__ == '__main__':
app.run(debug=True)

Sample code 2:
from flask import Flask, request, redirect, url_for
app = Flask(__name__)
@app.route('/')
def login():
return 'login'
@app.route('/profile/')
def profile():
name = request.args.get('name')
if not name:
return redirect('http://www.baidu.com') # Be careful : If you write directly here www.baidu.com Redirection is not possible , yes url The joining together of
else:
return redirect(url_for('login'))
if __name__ == '__main__':
app.run(debug=True)

边栏推荐
- Istio architecture extension mechanism
- The impact of Patrick mchardy incident on the open source community
- 监听div的滚动事件 @scroll
- 栈中的进行会消耗不能满足企业的功能,致力
- Four characteristics of nb-iot
- Worthington purified enzyme preparation helps neonatal cardiomyocyte isolation system
- PAT甲级 1043 Is It a Binary Search Tree
- DOM related method concepts
- mongo从开始到安装以及遇到的问题
- Method sharing of saving data to CSV file in MATLAB
猜你喜欢

How safe is Volvo XC90? Come and have a look

Histone research -- Characteristics and literature references of histones in Worthington calf thymus

Shengsi YiDianTong | deep learning analysis of classical convolutional neural network

Opening soon | openatom openharmony sub forum of 2022 open atom global open source summit "interconnection of all things, enabling thousands of industries"

Appendtofile append failed

Genesis public chain: Tamp the foundation of Web 3.0 development

Demining game (analysis)

Active vibration reduction system of hub motor and its vertical performance optimization

Learning summary | truly record what mindspire two-day training camp can bring to you (1)!

Technical dry goods | evaluation index based on mindspire detailed perflexity language model
随机推荐
Redis
[untitled]
4. Hezhou air32f103_ LCD
训练数据量不只适用于.z据接收方对数字视
Four characteristics of nb-iot
Why do some people write code so complicated?
MySQL learning - MySQL software installation and environment configuration (Windows) details!
CVE-2022-29464 WSO2文件上传漏洞
Active vibration reduction system of hub motor and its vertical performance optimization
Experiment 6 MPEG
训练赛《眼不见,心不烦,理不乱》题解
Embedded system transplantation [5] - Cross compilation tool chain
Basic syntax of MySQL DDL and DML and DQL
STL set容器
Istio architecture extension mechanism
Rpc-bdy (5) - automatic service logoff, load balancing
Technical dry goods | how difficult is data processing? Take a look at the solution provided by mindspire!
C language classic exercises (2) - "bubble sort"“
Prosci Lag3 antibody: improve in vitro research and help cancer immunotherapy
swagger2的初步使用