Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.8K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
I am struggling a dynamic form field, need guidance please.

In my Flask application I have 2 directories and 1 file.

directory1: templates

directory2: static

file: __ init __.py


My __ init __.py files content look like this (I know i have literally deleted all of my stupid request/get/post code so as not to confuse you and myself so that we can start from scratch.

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

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


if __name__ == "__main__":
app.run()


This is something i will add later to the page (but just wanted to let you know my intentions..


@app.route('/resultsPage')
def futurefunc():
#api call using string html from form field
#return results from api call
#pass those results onto another html page.


I have an index.html file in the templates directory. A css and a js file in the static directory.

The link below shows what my index.html page looks like and the HTML form code, JS and CSS code that supports it.

Link: http://codepen.io/hecalu/pen/EVQvmv

Overall it is a simple page with a search bar. But, for the life of me, and believe me, I have been trying for ages... to create a post request that takes information from the index pages form field and passes it into a python script (which I am planning to add later). This simple task has been so complicated for me because I have very limited basic knoweldge of JS, CSS and HTML. I hope that someone knows how i can pass a string from this specific form field as mentioned/shown in the link to a backend python script. In the future I hope to run an api call from the string entered and return the api results on a new page. Please, help me out, I am in dire need. Thank you!



/r/flask
https://redd.it/5xevzl