用tornado框架做后端……,用bootstrap做前端
先上效果圖:
生成出來的G代碼:
g.py源碼:
- #coding=utf-8
- # -*- coding: UTF-8 -*-
- #!/usr/bin/eny python
- #coding:utf-8
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- import tornado.ioloop
- import tornado.web
- class MainHandler(tornado.web.RequestHandler):
- def get(self):
- self.render('g.html')
- def post(self,*args,**kwargs):
- x='X'
- y='Y'
- g='G01'
- k=0
- a1=0
- e=''
- a=int(self.get_argument('x'))
- b=int(self.get_argument('y'))
- c=int(self.get_argument('r'))
- d=int(self.get_argument('l'))
- j1=int(self.get_argument('f'))
- q=(b/2)+6
- k=(-(a/2))
- while k<a:
- a1=a1=1
- i=a1%2
- if i==1:
- k=k+(c/2)
- q=q*-1
- l=g+x+str(k)+y+str(q)
- e=e+l+'</br>'
- c1=-(a/2)
- c2=(b/2)
- l1='G00'+str(c1)+y+str(c2)+'</br>'+"Z5"+'</br>'
- l2=g+'Z'+str(d)+'F'+str(j1)+'</br>'
- l3=str(q)
- l4=g+'Y'+l3+'F'+str(j1)+'</br>'
- tou=l1+l2+l4
- w1='G00'+'Z20'+'</br>'
- w2='G00'+'X0Y0'
- zhong=tou+e+w1+w2
- self.write(zhong)
- settings={
- }
- application = tornado.web.Application([
- (r"/index", MainHandler),
- ],)
- if __name__ == "__main__":
- application.listen(8000)
- tornado.ioloop.IOLoop.instance().start()
html源碼:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>在線G代碼平面銑工具</title>
- <link rel="stylesheet" >
- <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
- <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- </head>
- <body>
- <center><div style="width:550px;height:900px id="wingMap">
- <center><h1>在線G代碼平面銑工具</h1></center>
- ?<form method="post" action="/index">
- <form class="form-horizontal" role="form">
- <label for="firstname" class="col-sm-2 control-label">毛坯長(zhǎng)度</label>
- <input type="text" name="x" class="form-control" id="firstname"
- placeholder="請(qǐng)輸入毛坯長(zhǎng)度">
- <label for="lastname" class="col-sm-2 control-label">毛坯寬度:</label>
- <input type="text" name="y" class="form-control" id="lastname"
- placeholder="請(qǐng)輸入毛坯寬度:">
- <label for="lastname" class="col-sm-2 control-label">刀具直徑:</label>
- <input type="text" name="r" class="form-control" id="lastname"
- placeholder="請(qǐng)輸入刀具直徑:">
- <label for="lastname" class="col-sm-2 control-label">下刀深度:</label>
- <input type="text" name="l" class="form-control" id="lastname"
- placeholder="請(qǐng)輸入下刀深度:">
- <label for="lastname" class="col-sm-2 control-label">進(jìn)給速度:</label>
- <input type="text" name="f" class="form-control" id="lastname"
- placeholder="請(qǐng)輸入進(jìn)給速度F:">
- <button type="submit" name="submit" class="btn btn-primary">生成</button>
- </form>
- </form>
- </center>
效果圖
服務(wù)端效果圖:
生成速度非常快(10w行代碼只要幾秒)!
轉(zhuǎn)載于:https://www.cnblogs.com/ksxh/p/9051109.html
聯(lián)系客服