From 10a8ce7c7af4ca86fb77e2a3a59cf10af482a191 Mon Sep 17 00:00:00 2001 From: ColsonZhang <784278850@qq.com> Date: Tue, 26 Jan 2021 20:47:02 +0800 Subject: [PATCH] add some notes to READEME --- MyJade/reademe.md | 14 +++ README.md | 43 ++++++++-- Server/app.py | 5 +- .../handler/__pycache__/auth.cpython-36.pyc | Bin 2412 -> 2440 bytes Server/handler/__pycache__/js.cpython-36.pyc | Bin 0 -> 2685 bytes .../handler/__pycache__/spice.cpython-36.pyc | Bin 4195 -> 1664 bytes Server/handler/auth.py | 3 +- Server/handler/js.py | 66 ++++++++++++++ Server/handler/spice.py | 81 ++---------------- Server/template/index.html | 4 +- Server/template/spice/spice1.html | 2 +- 11 files changed, 134 insertions(+), 84 deletions(-) create mode 100644 MyJade/reademe.md create mode 100644 Server/handler/__pycache__/js.cpython-36.pyc create mode 100644 Server/handler/js.py diff --git a/MyJade/reademe.md b/MyJade/reademe.md new file mode 100644 index 0000000..cc11fd8 --- /dev/null +++ b/MyJade/reademe.md @@ -0,0 +1,14 @@ +## 有用的mxgraph's demo + +* dynamictoolbar.html +* permissions.html +* portrefs.html +* showregion.html +* standardsmode.html +* toolbar.html +* menustyle.html +* touch.html +* uiconfig.html +* userobject.html +* windows.html +* wires.html diff --git a/README.md b/README.md index 2d2ecd0..deb6adc 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,54 @@ # CZ_OpenSpice -# 项目简介 +## 项目简介 本项目旨在搭建一个web版本的spice电路仿真平台。当前项目仍处于不断更新中。 -# 项目框架 +## 项目框架 -## MyJade +### MyJade 能够绘制电路原理图的web前端代码,主要参考MIT的Jade项目。 -## Server +### Server 整个项目的后端服务器代码,主要基于Tornado、Bokeh框架开发。 -# 更新日志 +## 环境配置 +### Python环境 + +需要使用`python>=3.6`,同时需要安装如下几个python包,可以通过`pip install pkg-name`的方法进行安装,例如 `pip install tornado` + +* `tornado` +* `datetime` +* `pycket` +* `pymongo` +* `pymysql` + +### 数据库 + +需要安装如下几个数据库,并进行配置,配置的信息在`./Server/handler/MongoDB.py`和 + +`./Server/handler/MysqlDB.py`中均有记录 + +* `redis` +* `mysql` +* `mongodb` + +## 项目启动 + +进入`./Server/`路径,执行`python app.py` + +## 更新日志 + +* 2021年1月26日,修复了一些小bug,增加了一些配置信息 + + * 增加了README的内容 + * 再次测试代码,修复一些bug,例如注册时未往数据库中写入email等 + * 把部分js代码单独提取出来到一个文件夹下面 * 2021年1月22日,进一步完善服务器基本框架。 + * 基本尝试使用了BokehJS库的使用,计划用JS替代Python版本的Bokeh功能控件。 * 尝试Plotly的使用,计划作为Bokeh的备选。 * 尝试使用Javascript的Jquery库,利用ajax向服务器发送post请求传递信息。 @@ -25,6 +57,7 @@ * 后续需要在项目管理方面进行梳理,当前代码库已经存在一定的混乱。 * 将代码库中的`font-awesome`css库从本地删去,改为线上CDN加载。 * 2021年1月20日,完成了服务器基本框架的搭建。实现的功能有: + * 用户登录、认证、退出系统,新用户注册新账户 * 在mysql数据库中存储、更新用户基本信息 * 一个基本的仿真的app,功能为spice语言描述的电路传入后台,后台调用ngspice或xyce进行仿真(暂未对仿真结果进行处理,仅返回是否仿真成功) diff --git a/Server/app.py b/Server/app.py index ff346d8..59139ff 100644 --- a/Server/app.py +++ b/Server/app.py @@ -6,7 +6,7 @@ from handler import main, auth, spice # import _thread,threading # from spice import app_spice -define('port',default='8000',help='Listening port',type=int) #定义如何接受传进来的东西 +define('port',default='9000',help='Listening port',type=int) #定义如何接受传进来的东西 class Application(tornado.web.Application): #引入Application类,重写方法,这样做的好处在于可以自定义,添加另一些功能 @@ -16,7 +16,7 @@ class Application(tornado.web.Application): #引入Application类,重写方 (r'/login',auth.LoginHandler), (r'/logout',auth.LogoutHandler), (r'/register',auth.RegisterHandler), - # (r'/spice',spice.Spice_1_Handler), + (r'/spice1',spice.Spice_1_Handler), (r'/spice2',spice.Spice_2_Handler), (r'/spice3',spice.Spice_3_Handler), (r'/spice4',spice.Spice_4_Handler), @@ -60,3 +60,4 @@ if __name__ == '__main__': #当.py文件被直接运行时,代码块将被 app.listen(options.port) ##如果一个与define语句中同名的设置在命令行中被给出,那么它将成为全局的options的一个属性 即 options.port 相当于define的url的port print("Server start on port {}".format(str(options.port))) #提示服务启动占用端口 tornado.ioloop.IOLoop.current().start() #执行ioloop + diff --git a/Server/handler/__pycache__/auth.cpython-36.pyc b/Server/handler/__pycache__/auth.cpython-36.pyc index 26f0316e1ea50da0910f29067a457ad670bda14f..2612f5225dac54e85ce2b068a49aa179bdd26969 100644 GIT binary patch delta 217 zcmaDO)FI4i%*)H=$RLo=wvqD;8y^P)0|N^X`vY8izS7?yn{e3^_Oex6VXLkd5L1r+B<5dg7L7=jrz1^uFUiYB+Pi?Ok$ u<|bz5OrFWUmXTw!JBJ)ok>TVd4pm_ppfed5Ihc4D!H`LSk!SJ@jw=ADqcBSV delta 205 zcmeAWej~(b%*)I5U=>$F;6~0fY<%nt3=Awl><`4nGbTS~GpJ`SYN}xY;TqO#rlO`2 zrW)oNmS(0}wi>pgq7vpTmK3%c<`ni`CPoGzk2QrOg)@Z<#H(S*VoTv}W@Kb2oC0LC zr|_ikW-@~Kc|s)&DSRLnP@E%$AH+&w2xia}@QdOpN=?r!E=esa$S*D_;$xV+fSqIV mdiFJp?2}_SxQ%yXB%1t0f`ha1B8*78Ah}$R0PCG zl1LG|wVH!BOs)2hNd~v%oul+XiXzQUQG4i={kvMjwu&_yk~^{p$%l_Uva}y^UyIy# z-|W;Agp;ys3nmxRkXvpN^q5*aQs`RD0&xPz6@&|vHawfrDW4SzHV_zY1cZBM3zp^r zh@6sNSQg9FLEG!qW-VIhC?sCavfgb1AjW@4nf4}fQ4SPnFg?v~z-ucez-NgG$>G64 zdjosTByPQSv>7vtV+>jF49bvQC8i1yngptp*UC0T4GWe#pV;$MY_L0kA z+0N&aIo8U@LX_Lh+X{W~GEAoTksK56S5O14z0V1zpf#ISvX=?h1pjO~stw|}&E{<3 z>zqf>?~>g|jJ={xq+R$GDEqS;lD&)b;p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Server/handler/auth.py b/Server/handler/auth.py index 36929e7..21c4c08 100644 --- a/Server/handler/auth.py +++ b/Server/handler/auth.py @@ -52,11 +52,12 @@ class RegisterHandler(AuthBaseHandler): print('registerpost') username = self.get_argument('username','') + email = self.get_argument('email','') password1 = self.get_argument('password1','') password2 = self.get_argument('password2','') if username and password1 and (password1 == password2): - success = add_user(username,password1) + success = add_user(username,password1,email) if success: Mongo.connect(DataBase='example',Collection=username) Mongo.update(behavior='register',tags='auth') diff --git a/Server/handler/js.py b/Server/handler/js.py new file mode 100644 index 0000000..23e0721 --- /dev/null +++ b/Server/handler/js.py @@ -0,0 +1,66 @@ +js_import = """ + + + + + + + """ + +js_code_1 = """ + + """ \ No newline at end of file diff --git a/Server/handler/spice.py b/Server/handler/spice.py index d5320a8..e4e7ea5 100644 --- a/Server/handler/spice.py +++ b/Server/handler/spice.py @@ -1,90 +1,25 @@ from .main import AuthBaseHandler +from .js import js_import, js_code_1 import tornado.web -from bokeh.embed import server_document +# 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') + self.render('spice/spice1.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) + # 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) + self.render('spice/spice2.html',js_import=js_import,js_code=js_code_1) class Spice_3_Handler(AuthBaseHandler): diff --git a/Server/template/index.html b/Server/template/index.html index b845db5..115c602 100644 --- a/Server/template/index.html +++ b/Server/template/index.html @@ -8,8 +8,8 @@

我的第一个标题

我的第一个段落。

当前用户 {{user}}

-
-
+ +
diff --git a/Server/template/spice/spice1.html b/Server/template/spice/spice1.html index ca58ea2..13bb371 100644 --- a/Server/template/spice/spice1.html +++ b/Server/template/spice/spice1.html @@ -14,7 +14,7 @@ in the User's Guide.
- {% raw script %} + Hello,world !