Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Added stats api route
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrevinnoc committed Mar 9, 2021
1 parent e58b0c9 commit 7f2c854
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pip3 install -U pillow
pip3 install -U web3
pip3 install -U languagecodes
pip3 install -U banal
pip3 install -U psutil

python3 -m spacy download en_core_web_sm
python3 -c "import nltk; nltk.download('punkt')"
Expand Down
18 changes: 17 additions & 1 deletion future.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#########################################################################

from Monad import *
import os.path, os, shutil, json, random, sys, socket, re, mimetypes, datetime, lmdb, hnswlib, time, bson, requests, socket, ast, functools, asyncio, concurrent.futures, itertools, mimetypes, io, threading, languagecodes
import os.path, os, shutil, json, random, sys, socket, re, mimetypes, datetime, lmdb, hnswlib, time, bson, requests, socket, ast, functools, asyncio, concurrent.futures, itertools, mimetypes, io, threading, languagecodes, psutil
import numpy as np
import numexpr as ne
from flask import (Flask, render_template, request, redirect,
Expand Down Expand Up @@ -588,9 +588,25 @@ def _registerPeer():
overwrite=False)
peerRegistryTransaction.commit()

if hostname != "private":
listOfPeers.append(peerIP)
numberOfPeers += 1

return jsonify(result={"listOfPeers": listOfPeers})


@app.route('/_getPeerInfo')
def _getPeerInfo():
return jsonify(
result={
"uptime": time.time() - psutil.boot_time(),
"ip": hostIP,
"name": hostname,
"cpu": psutil.cpu_percent(),
"mem": psutil.virtual_memory().percent
})


@app.route('/_fetchSearxResults', methods=['GET'])
def fetchSearxResults():
query = request.args.get("query", 0, type=str)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ WTForms
languagecodes
banal
pymongo
psutil

0 comments on commit 7f2c854

Please sign in to comment.