Distributed and decentralized pi calculation

add pi length

+19 -2
+18 -2
src/server/app.py
··· 46 46 if piresult == "No clients have connected yet. Become one of the first!": 47 47 piresult = "No clients have connected. Become one of the first!" 48 48 else: 49 - piresult = "Current Pi count is " + piresult 49 + try: 50 + pilength = len(str(piresult)) 51 + print(pilength) 52 + pilen = "Current Pi length is " + str(pilength) 53 + except: 54 + pilen = "Current Pi length couldn't be calculated!" 55 + piresult = "Current Pi count is " + piresult + " digits!" 50 56 except: 51 57 piresult = "picalc/pi.txt wasn't found on this web server. Sorry!" 52 58 if request.method == 'GET': 53 59 ver = open("ver.txt", "r") 54 60 version = ver.read() 55 - return render_template('index.html', pi=piresult, name=name, email=email, version=version) 61 + return render_template('index.html', pi=piresult, name=name, email=email, version=version, pilen=pilen) 56 62 else: 57 63 return "Please use GET to access this page." 58 64 65 + @app.route('/api/getlen') 66 + def getlen(): 67 + f = open("picalc/pi.txt", "r") 68 + piresult = f.read() 69 + try: 70 + pilength = len(str(piresult)) 71 + return str(pilength) 72 + except: 73 + return "Pi length couldn't be found!" 74 + 59 75 @app.route('/api/getver') 60 76 def getver(): 61 77 try:
+1
src/server/templates/index.html
··· 25 25 <h1>Pistrubuted {{ version }}</h1> 26 26 <p>Pistrubuted is an open-source server & client to calculate Pi with distrubuted machines. Get started by downloading the client and connecting to this server.</p> 27 27 <p>{{ pi }}</p> 28 + <p>{{ pilen }}</p> 28 29 <hr> 29 30 <footer> 30 31 <p>This server is run by {{ name }}. Contact them at {{ email }} for support.</p>