Category : jinja2

python from flask import Flask, request, render_template from pytube import YouTube import pytube app = Flask(__name__) @app.route("/", methods=["POST", "GET"]) def find(): search1 = request.form.get("search") print(search1) print(type(search1)) subt = pytube.YouTube(search1) # <– Error occurs in this line. print(subt) cap = subt.captions.get_by_language_code(‘en’) print("Video english subtitle") print(cap.generate_srt_captions()) return render_template("sub.html") if __name__ == "__main__": app.run(debug=True) Error: TypeError: expected string ..

Read more

I am passing a variable in HTML form (using Jinja2 template ) to Flask as follows:- <form method=”post” action=”{{ ‘/goto/’ + value }}”> <button type=”submit” class=”btn btn-link”> {{ value }} </button> <input type=”hidden” value=”{{value}}” name=”{{value}}”> </form> where the variable value contains the string to be passed to the url. In Flask, the route function is ..

Read more

I’m trying to pass the coordinates for a polygon from my flask app to the html containing the mapbox gl using jinja2. My flask app looks something like this: @app.route(‘/<path:subpath>’, methods=[‘POST’, ‘GET’]) def show_subpath(subpath): if request.method == ‘POST’: try: data = request.form name = ‘Eine Karte’ poly = coords return render_template(‘/map.html’, name=name, polygon=poly) except: return ..

Read more

I have a DAG that’s running a few snowflake operators, and in the SQL files I have templated dates as follows: ‘{{ prev_execution_date.subtract(minutes=15).in_tz(‘America/Toronto’).to_datetime_string() }}’ ‘{{ execution_date.in_tz(‘America/Toronto’).to_datetime_string() }}’ This all works fine. I also want to be able to manually trigger the DAG and pass in the date as well, so I tried the following in ..

Read more