架构RESTFul C ++ API以与Python交互 [英] Architecting a RESTFul C++ api to interface with Python

查看:204
本文介绍了架构RESTFul C ++ API以与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:

  • 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆