2017-12-28 11 views
-1

のHTMLフォームの入力値を渡すだから私は、HTMLフォームの入力を持っており、基本的に私は私入力し、私のapp.routeにそれを渡す(/ sometext/inputValueで)のpythonフラスコ

@app.route('/inputvalue') 
def index(): 
    return render_template('index.html') 

答えて

0

値を取りたいですあなたは、POSTGETメソッドを使用して、アプリケーションによってフォーム要求をキャプチャする必要があります。そのためには、ログインメソッドが必要です。 このようなもの

# you don't need to redirect the template 
from flask import Flask, redirect, url_for, request 
@app.route('/login', methods=['POST', 'GET']) 
def login(): 

    if request.method == 'POST': 
     user = request.form['Email'] # suppose you have a email and password field 
     passe = request.form['passw'] 

     return redirect(url_for('index', inputvalue=user)) # then you can pass email or pass 

及びこれらの事が行われており、サーバーが実行された後、あなたのhtmlファイル を開き、フォームを記入してください。リダイレクトされた値は、

@app.route('/inputvalue') 
def index(inputvalue): 
    return ('hey' + inputvalue) 
関連する問題