Flask
- 2 ответа
- 0 вопросов
2
Вклад в тег
from flask_wtf import Form, TextField, FileField
class PuziForm(Form):
image_url = TextField("label1")
image = FileField("label2")
@app.route('/test', methods=['GET', 'POST'])
def test():
form = PuziForm()
if form.validate_on_submit():
result = (form.image.data and form.image.data.read()) or form.image_url.data
else:
result = 'not submitted'
return render_template('test.html', form=form, result=result)
<form method="post" enctype=multipart/form-data>
{{ form.hidden_tag() }}
{% for element in form %}
{% if element.widget.input_type != 'hidden' %}
{{ element.label }} {{ element() }} <br>
{% endif %}
{% endfor %}
<input type="submit">
</form>
<br>
{{ result }}
D = TblAlertDescription
P = t_TBL_ALERT_PROJECTCORR
PRC = t_TBL_CONF_PROJECTRSSFEEDCORR
query = session. \
query(D.ALERT_ID). \
select_from(D). \
join(P). \
join(PRC, P.c.PROJECT_ID == PRC.c.PROJECT_ID). \
filter(D.STATUS_ID == 1,
D.alert_type_id == 5,
PRC.c.RSS_LOCATION_ID == 1)
print query
SELECT "TBL_ALERT_DESCRIPTION"."ALERT_ID" AS "TBL_ALERT_DESCRIPTION_ALERT_ID"
FROM "TBL_ALERT_DESCRIPTION" JOIN "TBL_ALERT_PROJECTCORR" ON "TBL_ALERT_DESCRIPTION"."ALERT_ID" = "TBL_ALERT_PROJECTCORR"."ALERT_ID" JOIN "TBL_CONF_PROJECTRSSFEEDCORR" ON "TBL_ALERT_PROJECTCORR"."PROJECT_ID" = "TBL_CONF_PROJECTRSSFEEDCORR"."PROJECT_ID"
WHERE "TBL_ALERT_DESCRIPTION"."STATUS_ID" = ? AND "TBL_ALERT_DESCRIPTION".alert_type_id = ? AND "TBL_CONF_PROJECTRSSFEEDCORR"."RSS_LOCATION_ID" = ?