Dec-06-2018, 04:49 PM
from API to ip
from API to ip
|
Dec-06-2018, 05:10 PM
In html, you could use a form: https://www.w3schools.com/tags/tag_form.asp
Or, if you want to do it programmatically, you could use javascript: https://www.w3schools.com/xml/ajax_intro.asp Or, if you're fine with adding jquery, https://api.jquery.com/jquery.post/ Without seeing some code, there isn't much help someone can give. (Dec-05-2018, 10:19 PM)whatl0ol Wrote: what does it mean?It's a demo getting value from my-form.html to server.So if i fix your first code(messy) it look like this. index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>whatl0ol</title> <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}"> </head> <body> <div class="login"> <div class="heading"> <h2></h2> <form action="{{ url_for('main') }}" method='POST'> <div class="input-group input-group-lg"> <span class="input-group-addon"><i class="fa fa-user"></i></span> <input type="text" name="input_field" class="form-control" placeholder=""> </div> <button type="submit" id="send" name="send" class="float">check</button> </form> </div> </div> </body> </html> app.py import requests from flask import Flask, jsonify, render_template, request app = Flask(__name__) @app.route('/') def template(): return render_template('index.html') @app.route('/main', methods=['POST']) def main(): form_input = request.form['input_field'] return(form_input) if __name__ == ("__main__"): app.run(debug=True)Run python app.py in browser paste http://127.0.0.1:5000/ So now get index.html rendered in browser.When send value will get catch it in server with request.form['input_field'] and send it back to browser return(form_input) Look at @nilamo links, and HTML Forms is a standard way to send stuff from client side(Browser) to server(Flask in this case) in web-development. |
|
Users browsing this thread: 2 Guest(s)