-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.py
53 lines (44 loc) · 1.42 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
from flask import Flask,render_template,url_for,redirect,request
from send import send
from receive import receive
from flask_compress import Compress
app = Flask(__name__)
COMPRESS_MIMEYPES = ['text/html','text/css','text/js']
COMPRESS_LEVEL = 6
COMPRESS_MIN_SIZE = 500
Compress(app)
@app.route('/success/<message>')
def success(message):
return render_template('success.html',message = message)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/sender',methods=['POST','GET'])
def sender():
if request.method == "GET":
return render_template('sender.html')
else:
path = request.form['path']
send(path,9999)
message = "SentSuccessfully"
return redirect(url_for('success',message = message))
@app.route('/receiver', methods = ['POST','GET'])
def receiver():
error = None
try:
if request.method == "GET":
return render_template('receiver.html')
else:
ip = request.form['ip']
receive(ip,9999)
message = "ReceivedSuccessfully"
return redirect(url_for('success',message = message))
except Exception as e:
error = "IP Invalid or change port"
return redirect(url_for('index'))
return render_template('index.html')
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html')
if __name__ == "__main__":
app.run(debug=True)