Import flask form data in javascript












0















I am trying to make a script that will ask a person for a clothing item and price, and then search for it on google with google dorks. I am attempting to do this with flask (python), html, and javascript.



my __init__.py:



from flask import Flask, render_template, request
app = Flask(__name__)

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

@app.route('/result',methods = ['POST', 'GET'])
def result():
if request.method == 'POST':
result = request.form
print result.items()
return render_template("result.html",result = result)

if __name__ == '__main__':
app.run(debug = True)


my search.html:



<html>
<body>

<form action = "http://127.0.0.1:5000/result" method = "POST">
<p>Item: <input type = "text" name = "item" /></p>
<p>Price <input type = "text" name = "price" /></p>
<p><input type = "submit" value = "submit" /></p>
</form>

</body>
</html>


my result.html:



<script>
{% for key, value in result.items() %}
window.location='https://www.google.com/search?q=intitle="{{ value }}"'
{% endfor %}
</script>


If you print the form data, you get:




[('item', u'ITEM_USER_SEARCHED'), ('price', u'PRICE_USER_SEARCHED')]




Right now the script is only searching the second value, which in this case would be "PRICE_USER_SEARCHED". What should I do different?










share|improve this question


















  • 1





    I don't understand what you are trying to do. You can only redirect once, do why do you have that in a loop?

    – Daniel Roseman
    Nov 24 '18 at 22:54













  • with the script bit at the end I am using a google dork to search something through google. the loop was just how I knew to insert the data with flask into the html. What is the correct way to do this? Because right now it only searches the second value

    – Aiden Manansala
    Nov 24 '18 at 23:11
















0















I am trying to make a script that will ask a person for a clothing item and price, and then search for it on google with google dorks. I am attempting to do this with flask (python), html, and javascript.



my __init__.py:



from flask import Flask, render_template, request
app = Flask(__name__)

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

@app.route('/result',methods = ['POST', 'GET'])
def result():
if request.method == 'POST':
result = request.form
print result.items()
return render_template("result.html",result = result)

if __name__ == '__main__':
app.run(debug = True)


my search.html:



<html>
<body>

<form action = "http://127.0.0.1:5000/result" method = "POST">
<p>Item: <input type = "text" name = "item" /></p>
<p>Price <input type = "text" name = "price" /></p>
<p><input type = "submit" value = "submit" /></p>
</form>

</body>
</html>


my result.html:



<script>
{% for key, value in result.items() %}
window.location='https://www.google.com/search?q=intitle="{{ value }}"'
{% endfor %}
</script>


If you print the form data, you get:




[('item', u'ITEM_USER_SEARCHED'), ('price', u'PRICE_USER_SEARCHED')]




Right now the script is only searching the second value, which in this case would be "PRICE_USER_SEARCHED". What should I do different?










share|improve this question


















  • 1





    I don't understand what you are trying to do. You can only redirect once, do why do you have that in a loop?

    – Daniel Roseman
    Nov 24 '18 at 22:54













  • with the script bit at the end I am using a google dork to search something through google. the loop was just how I knew to insert the data with flask into the html. What is the correct way to do this? Because right now it only searches the second value

    – Aiden Manansala
    Nov 24 '18 at 23:11














0












0








0








I am trying to make a script that will ask a person for a clothing item and price, and then search for it on google with google dorks. I am attempting to do this with flask (python), html, and javascript.



my __init__.py:



from flask import Flask, render_template, request
app = Flask(__name__)

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

@app.route('/result',methods = ['POST', 'GET'])
def result():
if request.method == 'POST':
result = request.form
print result.items()
return render_template("result.html",result = result)

if __name__ == '__main__':
app.run(debug = True)


my search.html:



<html>
<body>

<form action = "http://127.0.0.1:5000/result" method = "POST">
<p>Item: <input type = "text" name = "item" /></p>
<p>Price <input type = "text" name = "price" /></p>
<p><input type = "submit" value = "submit" /></p>
</form>

</body>
</html>


my result.html:



<script>
{% for key, value in result.items() %}
window.location='https://www.google.com/search?q=intitle="{{ value }}"'
{% endfor %}
</script>


If you print the form data, you get:




[('item', u'ITEM_USER_SEARCHED'), ('price', u'PRICE_USER_SEARCHED')]




Right now the script is only searching the second value, which in this case would be "PRICE_USER_SEARCHED". What should I do different?










share|improve this question














I am trying to make a script that will ask a person for a clothing item and price, and then search for it on google with google dorks. I am attempting to do this with flask (python), html, and javascript.



my __init__.py:



from flask import Flask, render_template, request
app = Flask(__name__)

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

@app.route('/result',methods = ['POST', 'GET'])
def result():
if request.method == 'POST':
result = request.form
print result.items()
return render_template("result.html",result = result)

if __name__ == '__main__':
app.run(debug = True)


my search.html:



<html>
<body>

<form action = "http://127.0.0.1:5000/result" method = "POST">
<p>Item: <input type = "text" name = "item" /></p>
<p>Price <input type = "text" name = "price" /></p>
<p><input type = "submit" value = "submit" /></p>
</form>

</body>
</html>


my result.html:



<script>
{% for key, value in result.items() %}
window.location='https://www.google.com/search?q=intitle="{{ value }}"'
{% endfor %}
</script>


If you print the form data, you get:




[('item', u'ITEM_USER_SEARCHED'), ('price', u'PRICE_USER_SEARCHED')]




Right now the script is only searching the second value, which in this case would be "PRICE_USER_SEARCHED". What should I do different?







python flask






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 22:52









Aiden ManansalaAiden Manansala

11




11








  • 1





    I don't understand what you are trying to do. You can only redirect once, do why do you have that in a loop?

    – Daniel Roseman
    Nov 24 '18 at 22:54













  • with the script bit at the end I am using a google dork to search something through google. the loop was just how I knew to insert the data with flask into the html. What is the correct way to do this? Because right now it only searches the second value

    – Aiden Manansala
    Nov 24 '18 at 23:11














  • 1





    I don't understand what you are trying to do. You can only redirect once, do why do you have that in a loop?

    – Daniel Roseman
    Nov 24 '18 at 22:54













  • with the script bit at the end I am using a google dork to search something through google. the loop was just how I knew to insert the data with flask into the html. What is the correct way to do this? Because right now it only searches the second value

    – Aiden Manansala
    Nov 24 '18 at 23:11








1




1





I don't understand what you are trying to do. You can only redirect once, do why do you have that in a loop?

– Daniel Roseman
Nov 24 '18 at 22:54







I don't understand what you are trying to do. You can only redirect once, do why do you have that in a loop?

– Daniel Roseman
Nov 24 '18 at 22:54















with the script bit at the end I am using a google dork to search something through google. the loop was just how I knew to insert the data with flask into the html. What is the correct way to do this? Because right now it only searches the second value

– Aiden Manansala
Nov 24 '18 at 23:11





with the script bit at the end I am using a google dork to search something through google. the loop was just how I knew to insert the data with flask into the html. What is the correct way to do this? Because right now it only searches the second value

– Aiden Manansala
Nov 24 '18 at 23:11












1 Answer
1






active

oldest

votes


















0














Why you not try to use ajax in to send data to server and there us a python library that is accesing google dorks?






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463062%2fimport-flask-form-data-in-javascript%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Why you not try to use ajax in to send data to server and there us a python library that is accesing google dorks?






    share|improve this answer




























      0














      Why you not try to use ajax in to send data to server and there us a python library that is accesing google dorks?






      share|improve this answer


























        0












        0








        0







        Why you not try to use ajax in to send data to server and there us a python library that is accesing google dorks?






        share|improve this answer













        Why you not try to use ajax in to send data to server and there us a python library that is accesing google dorks?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 '18 at 22:20









        Bogdan BibinaBogdan Bibina

        786




        786






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463062%2fimport-flask-form-data-in-javascript%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks