如何POST查询以形成处理程序文件?

时间:2015-09-29 15:26:37

标签: post https coldfusion

这种方法有点不正统,但我需要将查询值发布到表单处理程序中。我正在做的是从单独的数据库中获取查询,我需要将这些查询值发布到处理表单值以提交到不同数据库表的操作页面中。

在这种情况下,我没有表格;我只需要将查询的值发布到表单操作页面,该页面将这些值和其他生成的值发布到十几个不同的表中。我之所以这样做是因为处理表单值的表单处理程序页面有超过2,700行代码,它们接受这些值并对它们进行操作,运行大量IF ELSE操作来决定哪些表值应该根据其他价值观进行;所以简单地查询表并直接插入它们不是一种选择。

如何在不使用表单的情况下将查询值放入表单处理程序页面?

1 个答案:

答案 0 :(得分:3)

您可以在不使用带有<cfhttp>标记的表单的情况下发布到网页。您可以使用<cfhttpparam>标记附加查询值。如果您的查询返回多行,则必须使用循环,并且可能需要单独的线程。

使用import asyncio @asyncio.coroutine def handler(reader, writer): def send(msg): print("send to device: {}".format(msg)) writer.write((msg + '\n').encode()) print("device connected") while True: msg = yield from reader.readline() if not msg: print("device disconnected") break msg = msg.decode().strip() print("got from device: {}".format(msg)) if msg == 'VERSION': send('1') elif msg == 'STOP': send('OK') loop = asyncio.get_event_loop() coro = asyncio.start_server(handler, '0.0.0.0', 4510, loop=loop) server = loop.run_until_complete(coro) try: loop.run_forever() except KeyboardInterrupt: pass server.close() loop.run_until_complete(server.wait_closed()) loop.close() 执行<cfhttp>的示例(从上面链接的文档中获取):

POST