From 939058411ecae0c683076384a7f972f437516564 Mon Sep 17 00:00:00 2001 From: ColsonZhang <784278850@qq.com> Date: Fri, 22 Jan 2021 20:09:14 +0800 Subject: [PATCH] add mongodb & bokehjs --- README.md | 7 ++ Server/app.py | 12 ++- Server/handler/MongoDB.py | 31 ++++++ Server/handler/{database.py => MysqlDB.py} | 2 +- .../__pycache__/MongoDB.cpython-36.pyc | Bin 0 -> 1308 bytes .../__pycache__/MysqlDB.cpython-36.pyc | Bin 0 -> 1267 bytes .../__pycache__/account.cpython-36.pyc | Bin 649 -> 641 bytes .../handler/__pycache__/auth.cpython-36.pyc | Bin 2007 -> 2412 bytes .../handler/__pycache__/main.cpython-36.pyc | Bin 1529 -> 1489 bytes .../handler/__pycache__/spice.cpython-36.pyc | Bin 0 -> 4195 bytes Server/handler/account.py | 3 +- Server/handler/auth.py | 17 ++- Server/handler/main.py | 28 ++--- Server/handler/spice.py | 99 ++++++++++++++++++ .../__pycache__/app_spice.cpython-36.pyc | Bin 2418 -> 2411 bytes Server/template/{ => auth}/login.html | 0 Server/template/{ => auth}/register.html | 0 Server/template/index.html | 9 ++ Server/template/spice/spice1.html | 20 ++++ .../{spice.html => spice/spice1_jinja.html} | 0 Server/template/spice/spice2.html | 17 +++ Server/template/spice/spice3.html | 95 +++++++++++++++++ Server/template/spice/spice4.html | 31 ++++++ 23 files changed, 346 insertions(+), 25 deletions(-) create mode 100644 Server/handler/MongoDB.py rename Server/handler/{database.py => MysqlDB.py} (95%) create mode 100644 Server/handler/__pycache__/MongoDB.cpython-36.pyc create mode 100644 Server/handler/__pycache__/MysqlDB.cpython-36.pyc create mode 100644 Server/handler/__pycache__/spice.cpython-36.pyc rename Server/template/{ => auth}/login.html (100%) rename Server/template/{ => auth}/register.html (100%) create mode 100644 Server/template/spice/spice1.html rename Server/template/{spice.html => spice/spice1_jinja.html} (100%) create mode 100644 Server/template/spice/spice2.html create mode 100644 Server/template/spice/spice3.html create mode 100644 Server/template/spice/spice4.html diff --git a/README.md b/README.md index 468cbc3..24b4bcf 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ # 更新日志 +* 2021年1月22日,进一步完善服务器基本框架。 + * 基本尝试使用了BokehJS库的使用,计划用JS替代Python版本的Bokeh功能控件。 + * 尝试Plotly的使用,计划作为Bokeh的备选。 + * 尝试使用Javascript的Jquery库,利用ajax向服务器发送post请求传递信息。 + * 发现Python版本的Bokeh功能控件部署在服务器上存在的一些问题,包括后台终端无后台信息等,暂时将该功能控件禁用。 + * 新增Mongo数据库的使用,计划用来记录用户的行为数据;该数据库的部署已经完成;该数据库的python封装已完成雏形,但尚不完善,需要后续根据采集节点的设计进一步完善。 + * 后续需要在项目管理方面进行梳理,当前代码库已经存在一定的混乱。 * 2021年1月20日,完成了服务器基本框架的搭建。实现的功能有: * 用户登录、认证、退出系统,新用户注册新账户 * 在mysql数据库中存储、更新用户基本信息 diff --git a/Server/app.py b/Server/app.py index a7533bd..ff346d8 100644 --- a/Server/app.py +++ b/Server/app.py @@ -2,9 +2,9 @@ import tornado.ioloop #开启循环,让服务一直等待请求的到来 import tornado.web #web服务基本功能都封装在此模块中 import tornado.options #从命令行中读取设置 from tornado.options import define,options #导入包 -from handler import main, auth +from handler import main, auth, spice # import _thread,threading -from spice import app_spice +# from spice import app_spice define('port',default='8000',help='Listening port',type=int) #定义如何接受传进来的东西 @@ -16,7 +16,11 @@ class Application(tornado.web.Application): #引入Application类,重写方 (r'/login',auth.LoginHandler), (r'/logout',auth.LogoutHandler), (r'/register',auth.RegisterHandler), - (r'/spice',main.Spice_Xyce_Handler), + # (r'/spice',spice.Spice_1_Handler), + (r'/spice2',spice.Spice_2_Handler), + (r'/spice3',spice.Spice_3_Handler), + (r'/spice4',spice.Spice_4_Handler), + (r'/test',main.TestHandler), ] settings = dict( debug = False, #调试模式,修改后自动重启服务,不需要自动重启,生产情况下切勿开启,安全性 @@ -50,7 +54,7 @@ app = Application() #实例化 if __name__ == '__main__': #当.py文件被直接运行时,代码块将被运行;当.py文件以模块形式被导入时,代码块不被运行。 # 开启 bokeh 服务 - app_spice.app_spice_begin() + # app_spice.app_spice_begin() tornado.options.parse_command_line() app.listen(options.port) ##如果一个与define语句中同名的设置在命令行中被给出,那么它将成为全局的options的一个属性 即 options.port 相当于define的url的port diff --git a/Server/handler/MongoDB.py b/Server/handler/MongoDB.py new file mode 100644 index 0000000..9ea4ab3 --- /dev/null +++ b/Server/handler/MongoDB.py @@ -0,0 +1,31 @@ +from pymongo import MongoClient +import datetime + + +class Mongo_DB(): + + def __init__(self, Mongo_URL = 'mongodb://localhost:27017/'): + self.Client = MongoClient(Mongo_URL) + + def connect(self,DataBase = 'default', Collection = 'default'): + self.DataBase = self.Client[DataBase] + self.Collection = self.DataBase[Collection] + + def __insert(self, contents ): + if type(contents) == list: + self.Collection.insert_many(contents) + elif type(contents) == dict: + self.Collection.insert_one(contents) + else: + print("Data's format error !!!") + + + def update(self, behavior = '' , spice = '', tags = ''): + message = {} + message['behavior'] = behavior + message['spice'] = spice + message['tags'] = tags + message['date'] = datetime.datetime.utcnow() + self.__insert(message) + +Mongo = Mongo_DB() \ No newline at end of file diff --git a/Server/handler/database.py b/Server/handler/MysqlDB.py similarity index 95% rename from Server/handler/database.py rename to Server/handler/MysqlDB.py index b9385b5..abf9717 100644 --- a/Server/handler/database.py +++ b/Server/handler/MysqlDB.py @@ -10,7 +10,7 @@ table_name = "user_info" # 打开数据库连接 db = pymysql.connect( database_ip, database_user, database_passwd, database_name ) - +print('open mysql success !!!') # 使用cursor()方法获取操作游标 cursor = db.cursor() diff --git a/Server/handler/__pycache__/MongoDB.cpython-36.pyc b/Server/handler/__pycache__/MongoDB.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..992e6075d6e892648b8bc3ce60cd67f1ef8ba833 GIT binary patch literal 1308 zcmZux&2AGh5VpO$$##CIUQE^#CGRxX+H|$TaouWqJ zl)enFQuR<~hVN|eY!43ea$KaQR=k_5Y@C}xH{l;gvN{~)nH(HSbt={1 zB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vxu1|RNHJa z8n|r!41cMwNJ#txloM6$d9m3<@v3X8yZTY}ReiNz@9+2j{7vo>T>LJ*F1)T9zLZOatHCmW5-nmXHLjft&Kl+C0ii%R_;Z+B+#N1M zc!YEOCCifq={g|2K0v*vL)|O3=tUzJQPS$H!W7OkYtLq&ovO{##<3Utwv&~etPs9= zk`?7Jaxq4fBARW5*#`>8^{lbBnAJ{N)3{&`1zKXVL|}9Qh_egMplHmn2Lu9O9W&S? zu}^|B>q2tCXcy7*X$z%KRwu5|1~s4AhECeIQ7|6!SoVby2Yi6K;<1Ru;;sLoPbWsh zz(r|FL8hter)f3QZAp5Zrcc_e>@414_y8~7d6&us=y9M76Wc6_h)2?|Twd-saLdc( zj^(P{KDsw+o7dL)`*@tPI^|uZqb{`A)Vv&d&=%osU-?4`^qvc~DNSSG9h~6W1(q%aoGcZMW$;+QNh4M*fJpr-?v%PC^;6UpHS3PZ^)&=xk3z@w zK=(HwTp1u<@VN8|7xoqt?LP{;g&6Gp7x7_^-VXkNmkTba|deJfqETJ z0`bEaA-qeP2l{f>e@gbxP+$XT^BjA~4)Z+eh>c(3SP?$LLd8EZ;C)Z`fxwj9xR{a^ z=P#|@SJL|yzVbP}w4%2HS{Y%#Qxygb)Z3F@mglo})%ChSsV(?w_xpGJ-*Cf4-*ye> SJNl<)sei?MAO`OZ`u_p>R;qCT diff --git a/Server/handler/__pycache__/main.cpython-36.pyc b/Server/handler/__pycache__/main.cpython-36.pyc index a8e9fb879c32ba67b6edb71cf9822f46937db741..0c2136bf8fc23a1215a8795dec5c6963043228b5 100644 GIT binary patch literal 1489 zcmbVMJ8u&~5Z=eVaoh zA^ZjS9W>ig;>H_-t5j!YJQ>5Jb?F z1QceLvWy3u62XO)TCd4-B5dJ&BEpe$WRD!lXI9|Ct}8s)^`txFfd~4E@Im)$eMQg# z>8_rEZPM>j(-_FIOp1IbIZg623cIjL@5Ok2@iACz!YHqSkaaWx6I8HIB;bOBJb24M_l=Y2Ql~UzVCcDhIwv7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(YP{#Y#==&}PX8fXDW zDnndEvWVmol24IbM)Kb77}cZLs5?gfyxsBoneNyEt=N9+?ifAQT``<>ihj7VHG$%K zae&G3vZnER2TG4Yr{025867c7FV2b3m!P^kQeQU(^5;e9+IbPW_P-ILqb-aPD!n)- zLSKRErz7=%5b~|Yuo}@I78v&7h2rGqz`;$YX7@sVgyB&S&Te=*)aNpR>8BCaN>0^- fjyV>^uzn*y9^S-bw8Wu#vu@5?i}Q>37i<3lnyw=@ literal 0 HcmV?d00001 diff --git a/Server/handler/account.py b/Server/handler/account.py index d85e191..0ca8957 100644 --- a/Server/handler/account.py +++ b/Server/handler/account.py @@ -1,6 +1,5 @@ import datetime -from .database import * - +from .MysqlDB import * #用户密码匹配判断函数 def authenticate(username,password): diff --git a/Server/handler/auth.py b/Server/handler/auth.py index 8522075..36929e7 100644 --- a/Server/handler/auth.py +++ b/Server/handler/auth.py @@ -1,9 +1,10 @@ from .main import AuthBaseHandler from .account import authenticate, add_user +from .MongoDB import * class LoginHandler(AuthBaseHandler): def get(self,*args,**kwargs): - self.render('login.html') + self.render('auth/login.html') def post(self,*args,**kwargs): username = self.get_argument('username',None) @@ -15,11 +16,15 @@ class LoginHandler(AuthBaseHandler): if passed: # 保存cookie信息到redis数据库 self.session.set('username',username) #将前面设置的cookie设置为username,保存用户登录信息 - print(self.session.get('username')) + print(self.session.get('username')+' login success !!!') next_url = self.get_argument('next', '') # 获取之前页面的路由 if next_url: + Mongo.connect(DataBase='example',Collection=username) + Mongo.update(behavior='login',tags='auth') self.redirect(next_url) #跳转主页路由 else: + Mongo.connect(DataBase='example',Collection=username) + Mongo.update(behavior='login',tags='auth') self.redirect('/') else: self.write({'msg':'login fail'}) #不通过,有问题 @@ -28,6 +33,8 @@ class LoginHandler(AuthBaseHandler): class LogoutHandler(AuthBaseHandler): def get(self, *args, **kwargs): + Mongo.connect(DataBase='example',Collection=self.get_current_user()) + Mongo.update(behavior='logout',tags='auth') #self.session.set('username','') #将用户的cookie清除 self.session.delete('username') self.redirect('/login') @@ -39,7 +46,7 @@ class LogoutHandler(AuthBaseHandler): class RegisterHandler(AuthBaseHandler): def get(self, *args, **kwargs): print('register') - self.render('register.html') + self.render('auth/register.html') def post(self, *args, **kwargs): print('registerpost') @@ -51,9 +58,11 @@ class RegisterHandler(AuthBaseHandler): if username and password1 and (password1 == password2): success = add_user(username,password1) if success: + Mongo.connect(DataBase='example',Collection=username) + Mongo.update(behavior='register',tags='auth') self.redirect('/login') else: self.write({'msg':'register fail'}) else: print('register again') - self.render('register.html') \ No newline at end of file + self.render('auth/register.html') \ No newline at end of file diff --git a/Server/handler/main.py b/Server/handler/main.py index 32a9f23..b5ee32b 100644 --- a/Server/handler/main.py +++ b/Server/handler/main.py @@ -1,30 +1,30 @@ import tornado.web from pycket.session import SessionMixin -from bokeh.embed import server_document -from jinja2 import Environment, FileSystemLoader +from .MongoDB import * -env = Environment(loader=FileSystemLoader('template')) class AuthBaseHandler(tornado.web.RequestHandler,SessionMixin): def get_current_user(self): #重写get_current_user()方法 return self.session.get('username',None) #session是一种会话状态,跟数据库的session可能不一样 - + #添加装饰器,装饰需要验证的请求 class IndexHandler(AuthBaseHandler): @tornado.web.authenticated #@tornado.web.authenticated装饰器包裹get方法时,表示这个方法只有在用户合法时才会调用,authenticated装饰器会调用get_current_user()方法获取current_user的值,若值为False,则重定向到登录url装饰器判断有没有登录,如果没有则跳转到配置的路由下去,但是要在app.py里面设置login_url def get(self,*args,**kwargs): - user = self.get_current_user() - self.render('index.html',user=user) + username = self.get_current_user() + self.render('index.html',user=username) +class TestHandler(AuthBaseHandler): + + @tornado.web.authenticated #@tornado.web.authenticated装饰器包裹get方法时,表示这个方法只有在用户合法时才会调用,authenticated装饰器会调用get_current_user()方法获取current_user的值,若值为False,则重定向到登录url装饰器判断有没有登录,如果没有则跳转到配置的路由下去,但是要在app.py里面设置login_url + def post(self,*args,**kwargs): + username = self.get_current_user() + message = self.get_argument('message') -class Spice_Xyce_Handler(AuthBaseHandler): + print('TestHandler: '+username+' '+message) + Mongo.connect(DataBase='example',Collection=username) + Mongo.update(behavior=message,tags='test') - @tornado.web.authenticated - def get(self,*args,**kwargs): - template = env.get_template('spice.html') - script = server_document('http://localhost:5006/bkapp') - self.write(template.render(script=script)) + self.write("success") - # script = server_document('http://localhost:5006/bkapp') - # self.render('spice.html',script=script) diff --git a/Server/handler/spice.py b/Server/handler/spice.py index e69de29..d5320a8 100644 --- a/Server/handler/spice.py +++ b/Server/handler/spice.py @@ -0,0 +1,99 @@ +from .main import AuthBaseHandler +import tornado.web +from bokeh.embed import server_document +# from jinja2 import Environment, FileSystemLoader + +class Spice_1_Handler(AuthBaseHandler): + + @tornado.web.authenticated + def get(self,*args,**kwargs): + # env = Environment(loader=FileSystemLoader('template')) + # template = env.get_template('spice.html') + # script = server_document('http://localhost:5006/bkapp') + # self.write(template.render(script=script)) + + script = server_document('http://localhost:5006/bkapp') + self.render('spice/spice1.html',script=script) + +class Spice_2_Handler(AuthBaseHandler): + + @tornado.web.authenticated + def get(self,*args,**kwargs): + js_import = """ + + + + + + + """ + js_code = """ + + """ + self.render('spice/spice2.html',js_import=js_import,js_code=js_code) + + +class Spice_3_Handler(AuthBaseHandler): + @tornado.web.authenticated + def get(self,*args,**kwargs): + self.render('spice/spice3.html') + + +class Spice_4_Handler(AuthBaseHandler): + @tornado.web.authenticated + def get(self,*args,**kwargs): + self.render('spice/spice4.html') \ No newline at end of file diff --git a/Server/spice/__pycache__/app_spice.cpython-36.pyc b/Server/spice/__pycache__/app_spice.cpython-36.pyc index 03e4910359cbcfb63a1465ab4a51f7b3004eaaf0..ba03993ca3ce2bc4925509df57b3446b01426cd1 100644 GIT binary patch delta 86 zcmew)^je71n3tEUriCj(XCvoL7DkWBk6Dx^^RU`6N^JIK4Pj&yo4kN+AEV*qc=i%T llg(Gy>lx))7#J9e#ef6{GY=yKPGJ{d6kz6%6k+0E1^~+35u*SA delta 93 zcmaDY^ht=*n3tF9rW8j4-$u@xER6n>AG0X2?Mpwo6oY>Gs-hFFfbI00SOK!9!3b9!Y;rlz|0{j!o
+
+
+
+
+
+
+
+
+
diff --git a/Server/template/spice/spice1.html b/Server/template/spice/spice1.html new file mode 100644 index 0000000..ca58ea2 --- /dev/null +++ b/Server/template/spice/spice1.html @@ -0,0 +1,20 @@ + + + + + + Embedding a Bokeh Server With + + + +
+ This Bokeh app below served by a Bokeh server that has been embedded + in another web app framework. For more information see the section + Embedding Bokeh Server as a Library + in the User's Guide. +
+
+ {% raw script %} +
+ + diff --git a/Server/template/spice.html b/Server/template/spice/spice1_jinja.html similarity index 100% rename from Server/template/spice.html rename to Server/template/spice/spice1_jinja.html diff --git a/Server/template/spice/spice2.html b/Server/template/spice/spice2.html new file mode 100644 index 0000000..1ead21e --- /dev/null +++ b/Server/template/spice/spice2.html @@ -0,0 +1,17 @@ + + + + + + Complete Example + + {% raw js_import %} + + + +
+ {% raw js_code %} +
+ + + diff --git a/Server/template/spice/spice3.html b/Server/template/spice/spice3.html new file mode 100644 index 0000000..ad53e34 --- /dev/null +++ b/Server/template/spice/spice3.html @@ -0,0 +1,95 @@ + + + + + + Complete Example + + + + + + + + + +
+ + +
+ +
+ +
+ + + diff --git a/Server/template/spice/spice4.html b/Server/template/spice/spice4.html new file mode 100644 index 0000000..b75d696 --- /dev/null +++ b/Server/template/spice/spice4.html @@ -0,0 +1,31 @@ + + + + + + + + + + + +