单个电子邮件验证器在刷新后显示结果,但我必须在同一页面中显示我的结果

时间:2018-05-23 05:02:46

标签: html json python-3.x

<form target="_blank" action="{{ url_for('handle_email') }}" method="post"

 id="email">
    <div class="splash">
        <input type="text" class="input-box" id="email" placeholder="enter email here" name="email">
        <p class="splash-subhead">
        Email spider can find thousand of emails in seconds.
        </p>

        <p>
            <input type="submit" value="Submit" class="pure-button" id="search-btn" value="Get Started">
        </p>

这是我的PYTHON代码。

@app.route('/email', methods=['POST'])
def handle_email():
    email = request.form['email']
    url = "http://spiderapi.herokuapp.com/api/emails/"
    print("requesting: ", url)
    headers = {'Content-type': 'application/json'}
    r = requests.post(url, json={"email": email, "key": "C88B933A691E16C56EBC92BCC9A7E"}, headers=headers)
    print(r.json())
    if r.status_code == 200:
        return jsonify(r.json()), 200
    else:
        return jsonify({"response": " Something when wrong ", "status_code": 400});

这是一个简单的电子邮件验证器代码,我想在同一个HTML页面上返回我的电子邮件的结果,无论它是有效还是无效。现在它正在刷新页面并显示结果。

0 个答案:

没有答案