Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
from API to ip
(Dec-06-2018, 04:49 PM)nilamo Wrote: By submitting it in a post request.

how ?
In html, you could use a form:
Or, if you want to do it programmatically, you could use javascript:
Or, if you're fine with adding jquery,

Without seeing some code, there isn't much help someone can give.
(Dec-05-2018, 10:19 PM)whatl0ol Wrote: what does it mean?
def my_form():
    return render_template('my-form.html')

@app.route('/', methods=['POST'])
def my_form_post():
    text = request.form['text']
    processed_text = text.upper()
    return processed_text 
It's a demo getting value from my-form.html to server.
So if i fix your first code(messy) it look like this.
<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">

  <div class="login">
    <div class="heading">
      <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="">
        <button type="submit" id="send" name="send" class="float">check</button>
import requests
from flask import Flask, jsonify, render_template, request

app = Flask(__name__)
def template():
   return render_template('index.html')
@app.route('/main', methods=['POST'])
def main():
    form_input = request.form['input_field']

if __name__  == ("__main__"):
Run python in browser paste
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.

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)