Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1af6cc1

Browse files
[feat]: Added main module consisting of flask application
1 parent 5c158b1 commit 1af6cc1

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

‎Google-Image-Scrapper/main.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from flask import Flask, render_template, request,flash,redirect,send_from_directory
2+
from scrapper import simple_image_download
3+
from flask_bootstrap import Bootstrap
4+
from flask_wtf import FlaskForm
5+
from wtforms import StringField, SubmitField, IntegerField,SelectField
6+
from wtforms.validators import DataRequired, Email
7+
import os
8+
9+
app = Flask(__name__, template_folder='templates')
10+
response = simple_image_download()
11+
app.secret_key = 'tO$&!|0wkamvVia0?n$NqIRVWOG'
12+
bootstrap = Bootstrap(app)
13+
downloaded = [False]
14+
image_request = {'name':'','number_of_images':0}
15+
16+
class ImageForm(FlaskForm):
17+
name = StringField('name', validators=[DataRequired()])
18+
number_of_images = IntegerField('number_of_images', validators=[DataRequired()])
19+
submit = SubmitField('Submit')
20+
21+
@app.route('/', methods=['GET', 'POST'])
22+
def index():
23+
form = ImageForm()
24+
if form.validate_on_submit():
25+
image_request['name'] = request.form['name']
26+
image_request['number_of_images'] = request.form['number_of_images']
27+
flash('Your images are being downloaded. Please wait.')
28+
downloaded[0] = True
29+
return redirect('/')
30+
31+
if downloaded[0]:
32+
response.download(image_request['name'] , int(image_request['number_of_images']))
33+
flash('All of your images have been downloaded')
34+
downloaded[0] = False
35+
return redirect('/')
36+
return render_template('index.html' , form = form)
37+
38+
if __name__ == '__main__':
39+
app.run(host="0.0.0.0", port=8000)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /