|
@@ -0,0 +1,106 @@
|
|
|
+from wechat_action.sql_models import DB
|
|
|
+from settings import using_config
|
|
|
+import tornado.ioloop
|
|
|
+import tornado.web
|
|
|
+import json
|
|
|
+from wechat_action import sql_tools
|
|
|
+# TODO:需要添加上supervisor,来维护进程
|
|
|
+# TODO:有时间需要对tornado进行改进
|
|
|
+
|
|
|
+
|
|
|
+db = DB(config=using_config)
|
|
|
+
|
|
|
+
|
|
|
+# 1.实现本机服务
|
|
|
+# 2.实现线上docker-selenium服务
|
|
|
+
|
|
|
+class login(tornado.web.RequestHandler):
|
|
|
+ # 0.登录,
|
|
|
+ # 1.成功---
|
|
|
+ # 2.不超过,返回一个二维码
|
|
|
+ def get(self):
|
|
|
+ self.write("Hello, world")
|
|
|
+
|
|
|
+ def post(self):
|
|
|
+ # 利用request属性
|
|
|
+ # 取出客户端提交的json字符串
|
|
|
+ jsonbyte = self.request.body
|
|
|
+ print('二进制格式json字符串:', jsonbyte)
|
|
|
+ jsonstr = jsonbyte.decode('utf8') # 解码,二进制转为字符串
|
|
|
+ print('json字符串:', jsonstr)
|
|
|
+
|
|
|
+ # 从json字符串转换为json对象,然后利用json对象提供的api
|
|
|
+ # 从json字符串中取出我想要的内容(解析json字符串)
|
|
|
+ jsonobj = json.loads(jsonstr) # 将字符串转为json对象
|
|
|
+ day = jsonobj.get('day') # 就可以用api取值
|
|
|
+ title = jsonobj.get('title')
|
|
|
+ print('day: ', day, ', title: ', title)
|
|
|
+
|
|
|
+ self.write('hello post')
|
|
|
+
|
|
|
+
|
|
|
+class create_ad_plan(tornado.web.RequestHandler):
|
|
|
+ # 1.批量创建计划
|
|
|
+ # 返回创建计划是否已经开始
|
|
|
+ def post(self):
|
|
|
+ # 1.
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+class create_ad_show(tornado.web.RequestHandler):
|
|
|
+ # 1.批量创建落地页
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+# TODO:数据库创建一批虚拟数据,供明天测试使用起
|
|
|
+# TODO:wechat_info,human_info 这两张表有空时需要进行对应改进
|
|
|
+class ad_status(tornado.web.RequestHandler):
|
|
|
+ # 1.创建情况
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+class ad_human_info(tornado.web.RequestHandler):
|
|
|
+ # 1.人群包获取
|
|
|
+ def get(self):
|
|
|
+ # 0.是否刷新
|
|
|
+ # 1.获取userid,以及是否刷新
|
|
|
+ user_id = self.get_argument("user_id", None)
|
|
|
+ is_refresh = self.get_argument("is_refresh", None)
|
|
|
+ if is_refresh:
|
|
|
+ # 1.返回二维码链接
|
|
|
+ # ----1.查看cookie是否可用
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ # 1.查看是否在刷新,
|
|
|
+ # 在刷新中,
|
|
|
+ # 返回正在刷新
|
|
|
+
|
|
|
+ # -------不管上面逻辑让他们多刷新几次
|
|
|
+ # 不在刷新
|
|
|
+ # 返回对应数据
|
|
|
+ # 2.获取userid对应数据
|
|
|
+ sql_session = db.DBSession()
|
|
|
+ sql_tools.get_human_info(sql_session=sql_session,user_id=user_id)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+class ad_wechat_info():
|
|
|
+ # 1.公众号相关信息获取
|
|
|
+ def get(self):
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+def make_app():
|
|
|
+ return tornado.web.Application([
|
|
|
+ (r"/create_ad_plan", create_ad_plan),
|
|
|
+ (r"/create_ad_show", create_ad_show),
|
|
|
+ ], debug=True)
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ app = make_app()
|
|
|
+ app.listen(8888)
|
|
|
+ tornado.ioloop.IOLoop.current().start()
|