The default Jinja delimiters are configured as follows:
{% ... %} for Statements
{{ ... }} for Expressions to print to the template output
for Comments not included in the template output
# ... ## for Line Statements
{% set result_count = result_list | length %}
{{ index | string ) }}
filter: length, string
debug html
url_for with params
python code
1 2 3 4 5 6 7 8 9 10 11 12
@app.route('/index') @app.route('/') defindex(): return'you are in the index page'
@app.route('/questions/<int:question_id>'): #int has been used as a filter that only integer will be passed # in the url otherwise it will give a 404 error
deffind_question(question_id): return ('you asked for question {0}'.format(question_id))
@app.route("/") defindex(): # return the rendered template return render_template("index.html")
defgenerate(): # grab global references to the output frame and lock variables global outputFrame, lock
# loop over frames from the output stream whileTrue: # wait until the lock is acquired with lock: # check if the output frame is available, otherwise skip # the iteration of the loop if outputFrame isNone: continue
# encode the frame in JPEG format (flag, encodedImage) = cv2.imencode(".jpg", outputFrame)
# ensure the frame was successfully encoded ifnot flag: continue
# yield the output frame in the byte format yield(b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + bytearray(encodedImage) + b'\r\n')
@app.route("/video_feed") defvideo_feed(): # return the response generated along with the specific media # type (mime type) return Response(generate(), mimetype = "multipart/x-mixed-replace; boundary=frame") #===================================================
{% set result_count = result_list | length %} <h1>Search Results #{{result_count}}</h1> {% for i in range(0,result_count) %} {% set item = result_list[i] %} {% set segimg_filepath = item["segimg_filepath"] %} {% set segmask_filepath = item["segmask_filepath"] %}
{% set img_height = item["height"] %} {% set img_width = item["width"] %}