3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

flaskでボタンで遷移したい

Last updated at Posted at 2020-06-07

SS 192.png  ポチッと押したら切り替わってほしい
##やること

flask で 「AAAA.html」の中にあるボタンを押したら「BBBB.html」に遷移する。

##環境

  • flask

##やり方

flaskのpythonの中身の一部

sample.py
from flask import Flask, request, render_template
app = Flask(__name__)

(中略)

@app.route("/BBBB", methods=["POST"])
def move_BBBB():
    return render_template("BBBB.html")

(後略)

POSTが来たらBBBB.htmlに遷移するようにしておく。

templates/AAAA.html
{% block content %}
<form action="/BBBB" method="POST">
    <input type="submit" value="ボタン">
</form>
{% endblock %}

AAAA.htmlの中にボタンを書いておく。
BBBB.htmlも準備しておく。

これでできていはいるようだけど、なにかダメな気がする。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?