Image-search / app.py
Aarifkhan's picture
Rename image.py to app.py
7a20ff9 verified
raw
history blame contribute delete
796 Bytes
from flask import Flask, render_template, request
from webscout import WEBS
import arrow
app = Flask(__name__)
@app.route('/', methods=['GET'])
def home():
keywords = request.args.get('keywords', 'india')
image_list = []
with WEBS() as webs_instance:
WEBS_images_gen = webs_instance.images(
keywords,
region="wt-wt",
safesearch="off",
size=None,
type_image=None,
layout=None,
license_image=None,
max_results=100
)
for r in WEBS_images_gen:
image_list.append(r)
print(r['image']) # Print the image URL to check if it's valid
return render_template('image.html', image=image_list, keywords=keywords)
if __name__ == '__main__':
app.run(debug=True)