I'm coming from PHP to python.
In PHP i do this:
$result = array();
foreach($videos as $video) {
$result[] = array("title"=>$video->title,"description"=>$video->title);
}
print_r($result);
Now when i try this in python flask i get an error We're sorry, but something went wrong: Web application could not be started
result = {}
for video in videos:
title = video['title']
description = video['description']
content = {'title':title, 'description': description}
result[] = content
How do i solve?
Here is full function
@app.route("/add_channel", methods=['POST'])
def add_channel():
if request.method == "POST":
id=request.form['channel']
videos = get_channel_videos(id)
result = []
for video in videos:
result.append({'id': video['id'], 'title': video['snippet']['title']})
return result