Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. from flask import Flask, render_template_string, request
  4. from wtforms import Form, TextField, SubmitField, HiddenField, validators, ValidationError, PasswordField, BooleanField, FieldList, widgets, SelectMultipleField
  5. app = Flask(__name__)
  6.  
  7. class SidForm(Form):
  8. submit = SubmitField("Add Services")
  9. # sid = SelectMultipleField('Channel choice',choices=[()])
  10. sid = SelectMultipleField(
  11. 'Channel choice',
  12. choices=[()], #chanlist
  13. option_widget=widgets.CheckboxInput(),
  14. widget=widgets.ListWidget(prefix_label=False)
  15. )
  16.  
  17.  
  18. template_form = """
  19. {% block content %}
  20. <form method="POST" action="/">
  21. <div>{{ form.language.label }} {{ form.language(rows=3, multiple=True) }}</div>
  22. <button type="submit" class="btn">Submit</button>
  23. </form>
  24. {% endblock %}
  25.  
  26. """
  27.  
  28. completed_template = """
  29. {% block content %}
  30. <div>{{ SL }}</div>
  31. {% endblock %}
  32.  
  33. """
  34.  
  35. @app.route('/', methods=['GET', 'POST'])
  36. def index():
  37. form = SidForm(sid=[("kurac", "palac")])
  38. SIDS = form.sid.data
  39. print type(form.sid)
  40. return render_template_string(completed_template, SL=SIDS)
  41.  
  42.  
  43. if __name__ == '__main__':
  44. app.run(debug=True, host='0.0.0.0')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement