Add server
This commit is contained in:
parent
f0f2b30e80
commit
3516559260
34
dump.py
34
dump.py
@ -1,16 +1,36 @@
|
|||||||
|
#Json
|
||||||
import json
|
import json
|
||||||
def read():
|
def read():
|
||||||
global db
|
global db
|
||||||
with open('db.json', 'r') as openfile:
|
with open('db.json', 'r') as openfile:
|
||||||
db = json.load(openfile)
|
db = json.load(openfile)
|
||||||
|
|
||||||
read()
|
|
||||||
|
|
||||||
for i in db:
|
|
||||||
ttime = db[i]
|
|
||||||
|
|
||||||
hours = ttime//60//60 ; ttime = ttime - hours*60*60
|
def dump():
|
||||||
minutes = ttime//60 ; ttime = ttime - minutes*60
|
read()
|
||||||
seconds = ttime
|
for i in db:
|
||||||
|
ttime = db[i]
|
||||||
|
|
||||||
|
hours = ttime//60//60 ; ttime = ttime - hours*60*60
|
||||||
|
minutes = ttime//60 ; ttime = ttime - minutes*60
|
||||||
|
seconds = ttime
|
||||||
|
|
||||||
|
return f'{i[:i.find("[")]} >> {hours}:{minutes}:{seconds}'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Simple server
|
||||||
|
import tornado.httpserver, tornado.ioloop, tornado.web
|
||||||
|
|
||||||
|
class MainHandler(tornado.web.RequestHandler):
|
||||||
|
def get(self):
|
||||||
|
self.write(dump())
|
||||||
|
application = tornado.web.Application([
|
||||||
|
(r"/", MainHandler),
|
||||||
|
])
|
||||||
|
if __name__ == "__main__":
|
||||||
|
http_server = tornado.httpserver.HTTPServer(application)
|
||||||
|
http_server.listen(8888)
|
||||||
|
tornado.ioloop.IOLoop.instance().start()
|
||||||
|
|
||||||
print(f'{i} >> {hours}:{minutes}:{seconds}')
|
|
||||||
|
Loading…
Reference in New Issue
Block a user