架构RESTFul C ++ API以与Python交互 [英] Architecting a RESTFul C++ api to interface with Python
问题描述
我有一个用Python开发的Web应用程序,需要调用一些底层C ++代码来执行计算密集型任务.我目前正在使用集成在python中的C-api,但我想从根本上改变我的解决方案:我希望C ++代码直接从前端接收HTTP请求,并与python分开进行计算.我还希望使用户能够向C ++代码询问具有GET请求等的数据.C++与Postgres数据库进行连接(如果有关系的话).
I have a web-application developed in Python and need to make calls to some underlying C++ code for computationally intensive tasks. I'm currently using the C-api integrated in python, but I want to fundamentally change my solution: I want the C++ code to directly receive HTTP requests from the front end and to do its computation separate of python. I also want to enable the user to ask the C++ code for data with GET requests etc. The C++ interfaces with a Postgres database (if that matters).
我想知道你们中的任何人是否有一些技术建议或资源可以仔细研究?
I'm wondering if any of you have some technology suggestions or resources to go peruse through?
推荐答案
There's a pretty long discussion about this topic here that'll probably leave you unsatisfied. Bottom line is that there's no single best practice for this kind of thing. Choices seem boil down to one of these approaches:
- 以apache/ISAPI模块或以 一个FastCGI服务器.
- 在C ++进程中运行嵌入式Web服务器,例如 Libmicrohttpd .
- 使用功能更完善的C ++网络框架,例如硅(非常新,看起来很酷)或 pion .
- Run your C++ code behind a web server as an apache/ISAPI module or as a FastCGI server.
- Run an embedded web server in your C++ process like Libmicrohttpd.
- Use a more full-blown C++ web framework like Silicon (very new, looks pretty cool) or pion.
这篇关于架构RESTFul C ++ API以与Python交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!