-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
77 lines (65 loc) · 1.73 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
"""
Darkmask API
By ~ Darkmash
"""
from flask import Flask, request
from flask_cors import CORS
import logging
import zlib
app = Flask(__name__)
CORS(app)
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
def encode_url(url):
return zlib.compress(url.encode()).hex()
def decode_url(url):
return zlib.decompress(bytes.fromhex(url)).decode()
@app.route('/')
def main_func_():
print("PING__UPTIME")
return """
<meta
property="og:image"
content="https://cdn.discordapp.com/attachments/1023460179087470663/1062001193733337158/image.png"
/>
<meta
name="description"
content="An API for generating masked urls."
/>
<meta name="keywords" content="mask , url , darkmask ,darkmash , tools , startup , coders" />
<link
rel="icon"
type="image/png"
href="https://cdn.discordapp.com/attachments/1023460179087470663/1062001193733337158/image.png"
/>
<title>Darkmask API ~ Darkmash</title>
######## DARKMASH ~ DARKMASK API ~ V.1.0.0 ###################<br>
To use the service [GET - method] ,<br>
  /from <br>
    give the url as url in headers <br>
    returns a masked url <br>
##############################################################
"""
@app.route('/from', methods=['GET'])
def get():
url = request.headers.get("url")
return "https://Darkmask.darkmash.repl.co/" + encode_url(url)
@app.route('/<url>')
def random(url):
try:
url = decode_url(url)
if "https://" in url :
return f"""
<script>
location.href = '{url}';
</script>
"""
else:
return f"""
<script>
location.href = 'https://{url}';
</script>
"""
except:
return "Invalid Url.."
app.run(host="0.0.0.0", port=8080)