国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

Python flask框架實現(xiàn)瀏覽器點擊自定義跳轉(zhuǎn)頁面

瀏覽:37日期:2022-07-23 08:43:29

代碼如下

_init_.py

from flask import Flask, request, url_for, redirect, render_templateapp = Flask(__name__)@app.route(’/’)def index(): return render_template(’index.html’)@app.route(’/cool_form’, methods=[’GET’, ’POST’])def cool_form(): if request.method == ’POST’: # do stuff when the form is submitted # redirect to end the POST handling # the redirect can be to the same route or somewhere else return redirect(url_for(’index’)) # show the form, it wasn’t submitted return render_template(’cool_form.html’)

index.html

<!doctype html><html><body> <p><a href='http://www.intensediesel.com/bcjs/{{ url_for(’cool_form’) }}' rel='external nofollow' >Check out this cool form!</a></p></body></html>

cool_form.html

<!doctype html><html><body> <form method='post'> <button type='submit'>Do it!</button> </form></html>

運行結(jié)果

Python flask框架實現(xiàn)瀏覽器點擊自定義跳轉(zhuǎn)頁面

進入5000端口顯示如圖,點擊這個按鈕,跳到自定義的/cool_form頁面

Python flask框架實現(xiàn)瀏覽器點擊自定義跳轉(zhuǎn)頁面

代碼在github:https://github.com/qingnvsue/flask中的webbutton文件夾

在我的程序里我實現(xiàn)了在web頁面點擊加法器或者除法器按鈕進入相應(yīng)頁面

Python flask框架實現(xiàn)瀏覽器點擊自定義跳轉(zhuǎn)頁面

Python flask框架實現(xiàn)瀏覽器點擊自定義跳轉(zhuǎn)頁面

Python flask框架實現(xiàn)瀏覽器點擊自定義跳轉(zhuǎn)頁面

代碼在github:https://github.com/qingnvsue/flask中的add文件夾

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 孙吴县| 福贡县| 衡山县| 饶平县| 宜黄县| 武鸣县| 甘肃省| 沅陵县| 保定市| 北碚区| 河间市| 威信县| 越西县| 陆丰市| 绥阳县| 什邡市| 无极县| 沙坪坝区| 北安市| 宁化县| 江津市| 彰化市| 梓潼县| 民乐县| 张家港市| 封丘县| 高台县| 阆中市| 巴南区| 昌乐县| 隆回县| 正阳县| 大冶市| 大关县| 平江县| 平武县| 霞浦县| 晋江市| 沅陵县| 萨嘎县| 东辽县|