-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.py
131 lines (90 loc) · 3.26 KB
/
app.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
from flask import Flask, render_template, redirect, url_for, send_file, request
from imports.ErrAutoSearch import main_func
from werkzeug.utils import secure_filename
from flask_socketio import SocketIO, emit
import os
UPLOAD_FOLDER = os.path.dirname(os.path.abspath(__file__))
ALLOWED_EXTENSIONS = {'py'}
app = Flask(__name__)
socketio = SocketIO(app, cors_allowed_origins="*")
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
def messageRecived():
print('message was received!!!')
@app.route('/')
def index():
return render_template('home.html')
@app.route('/landingPage')
def home():
return render_template('landingPage.html')
@app.route('/team')
def team():
return render_template('team.html')
@app.route('/autoErrCheck')
def fileupload():
return render_template('stackOverflow.html')
@app.route('/websiteBlocker')
def websiteBlocker():
return render_template('websiteBlocker.html')
@app.route('/boilerplateGenerator')
def boilerplateGenerator():
return render_template('boilerplateGenerator.html')
@app.route('/search', methods=['GET', 'POST'])
def search():
if request.method == 'POST':
if 'file' not in request.files:
print('No file attached in request')
return redirect('/dashboard')
file = request.files['file']
if file.filename == '':
print('No file selected')
return redirect('/')
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
result = main_func()
print(result)
return render_template('stackOverflow.html', result=result)
return redirect('/autoErrCheck')
@app.route('/download')
def download_file():
path = "imports/zip_files/blocker.zip"
return send_file(path, as_attachment=True)
@app.route('/react-flask')
def download_file_1():
path = "imports/zip_files/boilerplates/react-flask-boilerplate.zip"
return send_file(path, as_attachment=True)
@app.route('/react-node')
def download_file_2():
path = "imports/zip_files/boilerplates/react-node-boilerplate.zip"
return send_file(path, as_attachment=True)
@app.route('/react-django')
def download_file_3():
path = "imports/zip_files/boilerplates/react-django-boilerplate.zip"
return send_file(path, as_attachment=True)
@app.route('/devchat')
def grpchat():
return render_template('devChat.html')
@app.route('/webmon')
def webmon():
return render_template('website_monitor.html')
@app.route('/downloadWm')
def download():
path = "imports/zip_files/screentime.zip"
return send_file(path, as_attachment=True)
@app.route('/Batrim')
def batrim():
return render_template('batteryReminder.html')
@app.route('/downloadBr')
def downloadBr():
path = "imports/zip_files/BatteryReminder.zip"
return send_file(path, as_attachment=True)
@socketio.on('my event')
def handle_my_custom_event(json):
#print('recived my event: ' + str(json))
socketio.emit('my response', json, callback=messageRecived)
if __name__ == '__main__':
socketio.run(app)
#socketio.run(app, debug=True)
# app.run()