Skip to content

Commit

Permalink
listWebsitesJson is now using an actual list, as well as ipFile usin…
Browse files Browse the repository at this point in the history
…g with open()
  • Loading branch information
Lvl4Sword authored Dec 14, 2023
1 parent 9d33f64 commit d4b242c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions cli/cyberPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,11 @@ def listWebsitesJson(self):

websites = Websites.objects.all()
ipFile = "/etc/cyberpanel/machineIP"
f = open(ipFile)
ipData = f.read()
with open(ipFile, 'r') as f:
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]

json_data = "["
checker = 0
json_data = []

for items in websites:
if items.state == 0:
Expand All @@ -155,14 +154,7 @@ def listWebsitesJson(self):
state = "Active"
dic = {'domain': items.domain, 'adminEmail': items.adminEmail, 'ipAddress': ipAddress,
'admin': items.admin.userName, 'package': items.package.packageName, 'state': state}

if checker == 0:
json_data = json_data + json.dumps(dic)
checker = 1
else:
json_data = json_data + ',' + json.dumps(dic)

json_data = json_data + ']'
json_data.append(dic)
final_json = json.dumps(json_data)
print(final_json)

Expand Down

0 comments on commit d4b242c

Please sign in to comment.