Browse Source

removing the form

master
zeroth 6 years ago
parent
commit
5d8ef7954e
  1. BIN
      __pycache__/config.cpython-35.pyc
  2. BIN
      __pycache__/contextualise.cpython-35.pyc
  3. BIN
      __pycache__/forms.cpython-35.pyc
  4. 24
      contextualise.py
  5. 14
      templates/description.html
  6. 2
      templates/layout.html

BIN
__pycache__/config.cpython-35.pyc

Binary file not shown.

BIN
__pycache__/contextualise.cpython-35.pyc

Binary file not shown.

BIN
__pycache__/forms.cpython-35.pyc

Binary file not shown.

24
contextualise.py

@ -73,9 +73,8 @@ def all():
return render_template('all.html', file=thefile, listingfiles=listingfiles, jsonfiles=jsonfiles, listofdicts=listofdicts, counter2=counter2)
@app.route('/description', methods=['GET', 'POST'])
@app.route('/description')
def description():
form = ReusableForm(request.form)
#pick a file but that will be done an other way later
thefile = listingfiles[positioninarray] #select one file from fullpath minus static/
@ -96,29 +95,10 @@ def description():
Your browser does not support the video tag.
</video> ''')
print (form.errors)
if request.method == 'POST' and form.validate():
return 'Success!'
# return render_template('description.html', form=form, file=thefile, listingdirectories=listingdirectories, listingfiles=listingfiles)
return render_template('description.html', form=form, file=thefile)
return render_template('description.html', file=thefile)
@app.route('/get-data', methods=['GET', 'POST'])
def savepost():
if request.method=='POST':
dict={'id':listingdirectories[positioninarray][13:],'name':request.form['name'],'email':request.form['email'],'friend':request.form['friend'],'content':request.form['content']}
# open with "a" if the file should concatenate content
#json file naming gone unique by adding time and date of submission
with open(listingdirectories[positioninarray]+"/"+now+"_data_file.json", "w") as write_file:
json.dump(dict, write_file)
return "The JSON file is ready."
#throw description and next item, wee need to iterate through the files
else:
return "Error"
if __name__ == '__main__':
app.run(debug=True)

14
templates/description.html

@ -17,19 +17,5 @@
{% endfor %}
-->
{% for message in form.name.errors %}
<div>{{ message }}</div>
{% endfor %}
<form method="POST" action="/get-data">
<fieldset>
{{ form.hidden_tag() }}
<div>{{ form.name.label }} {{ form.name }}</div>
<div>{{ form.email.label }} {{ form.email }}</div>
<div>{{ form.friend.label }} {{ form.friend }}</div>
<div>{{ form.content.label }} {{ form.content }}</div>
<div>{{ form.submit }}</div>
</fieldset>
</form>
</div>
{% endblock %}

2
templates/layout.html

@ -13,7 +13,7 @@
<ul class="menu">
<li><a href="{{ url_for('home') }}">Home</a></li>
<li><a href="{{ url_for('about') }}">About</a></li>
<li><a href="{{ url_for('description') }}">Form</a></li>
<li><a href="{{ url_for('description') }}">Description</a></li>
<li><a href="{{ url_for('all') }}">All files</a></li>
</ul>
</nav></strong>

Loading…
Cancel
Save