-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
155 lines (127 loc) · 4.52 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import os
from flask import (Flask, escape, render_template, request, send_file,
send_from_directory, url_for)
import BS_scrapper as BS
import CJ_scrapper as CJ
import IB_scrapper as IB
import RG_scrapper as RG
app = Flask(__name__)
@app.route('/')
def homepage():
return render_template('homepage.html')
@app.route('/IB', methods=['GET', 'POST'])
def Idlebrain():
error = None
try:
if request.method == 'GET':
url = request.args.get("url")
if url is not None:
print(f'\nURL: {url}\n')
IB_obj = IB.IB(url)
invalid_url = IB_obj.start()
zip_file_name = os.path.basename(IB_obj.imgs_dir) + '.zip'
if not invalid_url:
print(zip_file_name)
return {'status': 'False', 'filename': zip_file_name}
return {'status': 'True'}
else:
error = 'Invalid URL'
return render_template('IB.html', error=error)
except Exception as e:
print(f'EXCEPTION!\n{e}')
return {'status': 'Exception'}
@app.route('/RG', methods=['GET', 'POST'])
def ragalahari():
error = None
try:
if request.method == 'GET':
url = request.args.get("url")
if url is not None:
print(f'\nURL: {url}\n')
(invalid_url, dir_name) = RG.start(url)
zip_file_name = os.path.basename(dir_name) + '.zip'
if not invalid_url:
print(zip_file_name)
return {'status': 'False', 'filename': zip_file_name}
return {'status': 'True'}
else:
error = 'Invalid URL'
return render_template('RG.html', error=error)
except Exception as e:
print(f'EXCEPTION!\n{e}')
return {'status': 'Exception'}
@app.route('/CJ', methods=['GET', 'POST'])
def cinejosh():
error = None
try:
if request.method == 'GET':
url = request.args.get("url")
if url is not None:
print(f'\nURL: {url}\n')
(invalid_url, dir_name) = CJ.start(url)
zip_file_name = os.path.basename(dir_name) + '.zip'
if not invalid_url:
print(zip_file_name)
return {'status': 'False', 'filename': zip_file_name}
return {'status': 'True'}
else:
error = 'Invalid URL'
return render_template('CJ.html', error=error)
except Exception as e:
print(f'EXCEPTION!\n{e}')
return {'status': 'Exception'}
@app.route('/BS', methods=['GET', 'POST'])
def bst():
error = None
try:
if request.method == 'GET':
url = request.args.get("url")
if url is not None:
print(f'\nURL: {url}\n')
(invalid_url, dir_name) = BS.start(url)
zip_file_name = os.path.basename(dir_name) + '.zip'
if not invalid_url:
print(zip_file_name)
return {'status': 'False', 'filename': zip_file_name}
return {'status': 'True'}
else:
error = 'Invalid URL'
return render_template('BS.html', error=error)
except Exception as e:
print(f'EXCEPTION!\n{e}')
return {'status': 'Exception'}
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route('/download', methods=['GET', 'POST'])
def download():
if request.method == 'GET':
file_path = request.args.get("filepath")
if file_path is not None:
#print(f'\n\nFile_path: {file_path}\n\n')
path = os.path.join(os.getcwd(), file_path)
#print(f'\n\nFilepath: {path}\n\n')
return send_file(path, as_attachment=True)
else:
return "<p>Error</p>"
else:
return "<h3>Internal Error!</h3>"
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/privacy')
def privacy():
return render_template('privacy.html')
@app.route('/contact')
def contact():
return render_template('contact.html')
@app.route('/robots.txt')
@app.route('/sitemap.xml')
def static_from_root():
return send_from_directory(app.static_folder, request.path[1:])
@app.route('/privacy_policy')
def privacy_policy():
return render_template('privacy_policy.html')
if __name__ == '__main__':
app.run(debug=True)