0

I'm making a python code and using flask to make a webpage.I need to take input from this html page into python and after processing sending back to html page.How I can do so ?

`Blockquote from flask import Flask, render_template

  app = Flask(__name__)

   @app.route('/')

  def  home():
       return render_template("login.html")


  @app.route('/about/')

  def  about():
       return ('you wil get all sort of shayari here')

   if __name__ == "__main__":
       app.run() 
                  '
Ankit
  • 11
  • 3
  • 1
    Does this answer your question? [Send data from a textbox into Flask?](https://stackoverflow.com/questions/12277933/send-data-from-a-textbox-into-flask) – gittert Dec 06 '19 at 10:27

1 Answers1

0

You can achieve the same within a single view. Assume if you want to register user you can do something like this.

 @app.route("/register_user", methods=["GET", "POST"])
    def register_user():
        """Register user."""
        form = SomeForm() 
        # treat POST request 
        if form.validate_on_submit():
           # do something ... 
           # return redirect ... 


        # else response to GET request
        # return render_template... 

Let me know if this solves your problem.

  • I'm very new into programming world, basically I'm a network designer so logically I can underrstand the code. But few question's :-1 SomeForm is a function in which we can define validation process ? 2. how to put post and get request. – Ankit Dec 06 '19 at 11:50
  • Go ahead... Ask the questions what you are facing doubts in. – Shishir Dubey Dec 06 '19 at 11:53
  • @Ankit you can add get/post code separately like `if request.method == 'GET/POST'` – rajvi Dec 06 '19 at 12:42