|
|
|
@ -10,6 +10,62 @@ from utils.findfsdb import on_find
|
|
|
|
|
from core.route import Router
|
|
|
|
|
from io import BytesIO
|
|
|
|
|
#repl = '<?xml version=\'1.0\' encoding=\'utf-8\'?>\n<!DOCTYPE repositories SYSTEM "http://www.gentoo.org/dtd/repositories.dtd">'
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
try:
|
|
|
|
|
with open('./pkgs.json', 'tr') as fn:
|
|
|
|
|
data = fn.read()
|
|
|
|
|
pkg_list = json.loads(data)
|
|
|
|
|
print(pkg_list)
|
|
|
|
|
return json.dumps(pkg_list)
|
|
|
|
|
except Exception(e):
|
|
|
|
|
print(e)
|
|
|
|
|
return "404"
|
|
|
|
|
|
|
|
|
|
def set_settings_app(params):
|
|
|
|
|
config = load_config()
|
|
|
|
|
#param = self.path.replace("/?st_app=", "")
|
|
|
|
|
list_param = param.split(',')
|
|
|
|
|
print(list_param)
|
|
|
|
|
for i in list_param:
|
|
|
|
|
if i.startswith('port'):
|
|
|
|
|
port = int(i.split('=')[1])
|
|
|
|
|
elif i.startswith('Lang'):
|
|
|
|
|
Lang = i.split('=')[1]
|
|
|
|
|
|
|
|
|
|
write_config(port, Lang)
|
|
|
|
|
print(config)
|
|
|
|
|
print(param)
|
|
|
|
|
|
|
|
|
|
def search(pkg):
|
|
|
|
|
#param = self.path.replace("/find?pkg=", "") #request['params']['name']
|
|
|
|
|
Pk_list = []
|
|
|
|
|
Search_result = {}
|
|
|
|
|
if len(param.split('/')) == 2:
|
|
|
|
|
param = param.split('/')[1]
|
|
|
|
|
P_list = on_find(param)
|
|
|
|
|
print(p_list)
|
|
|
|
|
if len(P_list) == 0:
|
|
|
|
|
print("Never Found")
|
|
|
|
|
self.r_t = str(json.dumps({"Package_result": p_list}))
|
|
|
|
|
else:
|
|
|
|
|
for p in p_list:
|
|
|
|
|
print(p)
|
|
|
|
|
if len(param.split("/")) == 2:
|
|
|
|
|
Pk_list.append(search(param.split("/")[1]))
|
|
|
|
|
else:
|
|
|
|
|
Pk_list.append(search(param))
|
|
|
|
|
#print(pk)
|
|
|
|
|
Search_result = {"Package_result": Pk_list}
|
|
|
|
|
#self.r_t = str(json.dumps(search_result))
|
|
|
|
|
return str(json.dumps(Search_result))
|
|
|
|
|
#self.r_t = json.dumps(pkg_list)
|
|
|
|
|
def get_settings_app():
|
|
|
|
|
return str(json.dumps(load_config()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Handler(BaseHTTPRequestHandler):
|
|
|
|
|
def get_data(self):
|
|
|
|
|
#length = int(self.headers['content-length'])
|
|
|
|
@ -24,7 +80,7 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
|
|
|
|
|
|
|
def parse_url(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def do_GET(self):
|
|
|
|
|
|
|
|
|
|
#print(Router.parse_url(self))
|
|
|
|
|