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 26f0316..2612f52 100644 Binary files a/Server/handler/__pycache__/auth.cpython-36.pyc and b/Server/handler/__pycache__/auth.cpython-36.pyc differ diff --git a/Server/handler/__pycache__/js.cpython-36.pyc b/Server/handler/__pycache__/js.cpython-36.pyc new file mode 100644 index 0000000..ad3d5b7 Binary files /dev/null and b/Server/handler/__pycache__/js.cpython-36.pyc differ diff --git a/Server/handler/__pycache__/spice.cpython-36.pyc b/Server/handler/__pycache__/spice.cpython-36.pyc index 3729cf3..daf9d03 100644 Binary files a/Server/handler/__pycache__/spice.cpython-36.pyc and b/Server/handler/__pycache__/spice.cpython-36.pyc differ diff --git a/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}}
-