def test_data(): SQLModel.init_db() form = dict( username='******', password='******', role=UserRole.normal, ) u, result = User.register(form) # Session.add(u.id) # form = dict( # content='test weibo', # ) # w = Weibo.add(form, u.id) # form = dict( # id=1, # content='test comment', # user_id=1, # ) # id = Weibo.insert(form) # log('id', id) # # Weibo.comment_add(form, u.id) SQLModel.connection.close()
def run(host, port): SQLModel.init_db() log('开始运行于', 'http://{}:{}'.format(host, port)) with socket.socket() as s: s.bind((host, port)) s.listen() while True: connection, address = s.accept() log('ip {}'.format(address)) _thread.start_new_thread(process_request, (connection, ))
def test_data(): SQLModel.init_db() # Test.new({}) form = dict( username='******', password='******', role=UserRole.normal, ) u, result = User.register(form)
def run(host, port): # 初始化数据库 SQLModel.init_db() log('数据库链接初始化 <{}>'.format(SQLModel.connection.host_info)) log('开始运行于 http://{}:{}'.format(host, port)) # 初始化 socket with socket.socket() as s: s.bind((host, port)) s.listen() while True: connection, address = s.accept() log('请求地址 {}'.format(address)) _thread.start_new_thread(process_request, (connection, ))
def configured_app(): app = Flask(__name__) app.register_blueprint(public_bp) app.register_blueprint(user_bp) app.register_blueprint(weibo_bp) app.secret_key = secret_key SQLModel.init_db() app.errorhandler(404)(error_view) app.template_filter('formatted_time')(formatted_time) app.context_processor(current_time) return app
def test_data(): SQLModel.init_db() form = dict( username='******', password='******', role=UserRole.normal, ) u, result = User.register(form) form = dict( content='test weibo', comment='[]' ) w = Weibo.add(form, u.id)
def fake_data(): SQLModel.init_db() Test.new({}) form = dict( username='******', password='******', role=UserRole.normal, ) u, result = User.register(form) Session.add(u.id) form = dict(title='test todo ajax', ) t = TodoAjax.add(form, u.id)
def run(host, port): """ 启动服务器 """ # 初始化 ORM SQLModel.init_db() log('开始运行于', 'http://{}:{}'.format(host, port)) with socket.socket() as s: s.bind((host, port)) # 监听 接受 读取请求数据 解码成字符串 s.listen() # 无限循环来处理请求 while True: connection, address = s.accept() # 第二个参数类型必须是 tuple # log('ip {}'.format(address)) _thread.start_new_thread(process_request, (connection, ))
def test_data(): SQLModel.init_db() form = dict( username='******', password='******', role=UserRole.normal, ) u, result = User.register(form) form = dict(content='test weibo', ) w = Weibo.add(form, u.id) form = dict( content='test comment', weibo_id=w.id, ) Weibo.comment_add(form, u.id)
def run(host, port): """ 启动服务器 """ # 初始化数据库 SQLModel.init_db() log('数据库链接初始化 <{}>'.format(SQLModel.connection.host_info)) # 初始化 socket 套路 log('开始运行于 http://{}:{}'.format(host, port)) with socket.socket() as s: s.bind((host, port)) # 监听 接受 读取请求数据 解码成字符串 s.listen() # 无限循环来处理请求 while True: connection, address = s.accept() # 第二个参数类型必须是 tuple log('请求地址 {}'.format(address)) _thread.start_new_thread(process_request, (connection, ))
def fake_data(): SQLModel.init_db() Test.new({}) form = dict( username='******', password='******', role=UserRole.normal, ) u, result = User.register(form) Session.add(u.id) form = dict(title='test todo ajax', ) todo = Todo.add(form, u.id) t = TodoAjax.add(form, u.id) form = dict(content='test weibo', ) weibo = Weibo.add(form, u.id) comment = Comment.add(form, u.id)
def test_data(): SQLModel.init_db() Test.new({}) # guest user form = dict( username='******', password='******', role=UserRole.normal, ) u, result = User.register(form) Session.add(u.id) # test todo insert form = dict( title='test todo', user_id=u.id, ) Todo.insert(form) # test weibo insert form = dict( content='test weibo', user_id=u.id, ) weibo_id = Weibo.insert(form) # test comment insert form = dict( content='test comment', weibo_id=weibo_id, user_id=u.id, ) Comment.insert(form) SQLModel.connection.close()
def test_data(): SQLModel.init_db()
def test_data(): SQLModel.init_db() Test.new({})
def configured_app(): app = Flask(__name__) app.register_blueprint(public_bp) app.register_blueprint(user_bp) app.register_blueprint(weibo_bp) app.secret_key = secret_key SQLModel.init_db() app.errorhandler(404)(error_view) app.template_filter('formatted_time')(formatted_time) app.context_processor(current_time) return app if __name__ == '__main__': SQLModel.init_db() config = dict( debug=True, host='localhost', port=80, ) app = configured_app() log('url_map', app.url_map) app.run(**config) # def response_for_path(request): # """ # 根据 path 调用相应的处理函数 # 没有处理的 path 会返回 404 # """ # r = {}
def t_one(): SQLModel.init_db() one = User.all(role=UserRole.normal) log('user one', one)
def fake_data(): log('fake data') SQLModel.init_db() Test.new({}) form1 = dict( username='******', password='******', role=UserRole.normal, ) form2 = dict( username='******', password='******', role=UserRole.normal, ) u2, result = User.register(form1) u1, result = User.register(form2) Session.add(u1.id) Session.add(u2.id) form = dict(title='test todo ajax', ) t = TodoAjax.add(form, u1.id) # weibo form1 = dict( content="weibo test user zjt", user_id=u1.id, ) form2 = dict( content="weibo test user abc", user_id=u2.id, ) w1 = Weibo.add(form1, u1.id).id w2 = Weibo.add(form2, u2.id).id w1 = Weibo.add(form1, u2.id).id w2 = Weibo.add(form2, u1.id).id # comment form1 = dict( content="weibo test user zjt", user_id=u1.id, weibo_id=w1, ) form2 = dict( content="weibo test user abc", user_id=u2.id, weibo_id=w1, ) # comment form3 = dict( content="weibo test user zjt", user_id=u1.id, weibo_id=w2, ) form4 = dict( content="weibo test user abc", user_id=u2.id, weibo_id=w2, ) Comment.new(form1) Comment.new(form2) Comment.new(form3) Comment.new(form4) SQLModel.connection.close()