-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
36 lines (27 loc) · 847 Bytes
/
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
from flask import Flask, request
from fetch import *
import argparse
# Initialize parser
parser = argparse.ArgumentParser()
# Adding optional argument
parser.add_argument("-p", "--Port", help = "Port number", default = 65432)
# Read arguments from command line
args = parser.parse_args()
f = Fetch({
'http': 'socks5://127.0.0.1:'+str(args.Port),
'https': 'socks5://127.0.0.1:'+str(args.Port)
})
# version 1
if __name__ == "__main__":
app = Flask("pro_xy")
# make a get request and return response text
@app.route('/v1/get', methods=['GET'])
def get():
res = f.get(request.args.get("url"))
return res
# make a post request and return response text
@app.route('/v1/post', methods=['POST'])
def post():
res = f.post(request.json["url"], request.json["headers"], request.json["body"])
return res
app.run()