forked from s-katte/syngrafias
-
Notifications
You must be signed in to change notification settings - Fork 0
/
servdocs.py
68 lines (56 loc) · 2.51 KB
/
servdocs.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
from flask import Flask, render_template, request, jsonify
import click, time, json
servchat = Flask(__name__)
@servchat.route("/<themcolr>/")
def themable(themcolr):
return render_template("themable.html", sockport=sockp0rt, servport=servp0rt, themcolr=themcolr)
@servchat.route("/savedocs/")
def savedocs():
try:
username = request.args.get("username", "0", type=str)
workspec = request.args.get("workspec", "0", type=str)
docsname = request.args.get("docsname", "0", type=str)
document = request.args.get("document", "0", type=str)
curttime = time.time()
filename = username + "_" + workspec + "_" + str(curttime) + ".swd"
docsdict = {
"username": username,
"workspec": workspec,
"docsname": docsname,
"maketime": time.ctime(curttime),
"document": json.loads(document),
}
with open("static/docs/"+filename, "w") as jsonfile:
json.dump(docsdict, jsonfile)
return jsonify(result=filename)
except:
return jsonify(result="fail")
def colabnow(netpdata, servport):
servchat.run(host=netpdata, port=servport)
@click.command()
@click.option("-s", "--servport", "servport", help="Set the port value for Syngrafias [0-65536]", required=True)
@click.option("-c", "--sockport", "sockport", help="Set the port value for WebSockets [0-65536]", required=True)
@click.option("-6", "--ipprotv6", "netprotc", flag_value="ipprotv6", help="Start the server on an IPv6 address", required=True)
@click.option("-4", "--ipprotv4", "netprotc", flag_value="ipprotv4", help="Start the server on an IPv4 address", required=True)
@click.version_option(version="01082020", prog_name="Syngrafias Collaborator by t0xic0der")
def mainfunc(servport, sockport, netprotc):
global sockp0rt
sockp0rt = sockport
global servp0rt
servp0rt = servport
print(" * Starting Syngrafias...")
if servport == sockport:
print(" * [FAILMESG] The port values for Syngrafias server and WebSocket server cannot be the same!")
else:
print(" * Collaborator server started on port " + str(servport) + ".")
print(" * WebSocket server started on port " + str(sockport) + ".")
netpdata = ""
if netprotc == "ipprotv6":
print(" * IP version : 6")
netpdata = "::"
elif netprotc == "ipprotv4":
print(" * IP version : 4")
netpdata = "0.0.0.0"
colabnow(netpdata, servport)
if __name__ == "__main__":
mainfunc()