-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathlocal.py
63 lines (46 loc) · 1.56 KB
/
local.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
import sys
try:
import os
from flask import Flask, render_template, request
except:
print("Module not found\n Make sure you have installed 'requirements.txt' and configured DASH")
sys.exit(0)
__author__ = '0xprateek'
app = Flask(__name__)
@app.route("/")
def index():
try:
ip = request.environ['HTTP_X_FORWARDED_FOR'] # if behind a proxy
except KeyError:
ip = request.environ['REMOTE_ADDR']
with open('ip.bin', 'w') as file: # saving the ip in the file
file.write(ip)
return render_template("index.html")
@app.route("/upload", methods=['POST'])
def upload():
try:
ip = request.environ['HTTP_X_FORWARDED_FOR'] # if behind a proxy
except KeyError:
ip = request.environ['REMOTE_ADDR']
with open('ip.bin', 'w') as file: # saving the ip in the file
file.write(ip)
target = os.path.join(args.path)
print(target)
for file in request.files.getlist("file"):
print(file)
filename = file.filename
destination = "/".join([target, filename])
print(destination)
file.save(destination)
return '',204
if __name__ == "__main__":
try:
import argparse
parser = argparse.ArgumentParser()
except:
print("Module not found\n Make sure you have installed 'requirements.txt' and configured DASH")
sys.exit(0)
parser.add_argument('-port',help="Port address")
parser.add_argument('-path',help="Path address")
args = parser.parse_args()
app.run(port=args.port, debug=True)