新手:为网站编写后端代码
我通常在机器学习领域工作,因此我的背景主要是统计/机器学习,没有正式的网络背景。 通常对于我的项目,我使用连接到本地 mysql 数据库的 python 来获取数据和所有内容。 现在,我的工作基本完成了..一切都是基于控制台的.. (像传统程序一样)。 如何将其集成到前端。我知道这更像是服务器端脚本。 那么,让我们以谷歌为例。 在前端.. 有人输入搜索查询.. 在后端,假设有一个 C++ 程序执行该查询。 这种交互是如何发生的..如果前端是用 php 编写的.. 我认为 shell 执行程序是一种糟糕的运行程序的方式。? 任何建议将不胜感激。 谢谢
I am usually working in fields of machine learning and hence my background is mostly in stats/ML and no formal web background.
Usually for my project, I work on python which is connected to my local mysql db... to fetch data adn everything.
Now, my work is mostly complete.. everything is console based..
(like traditional programs).
How do I integrate it on the front end. I understand that this is more like a server side scripting.
So, lets take an example of google.
In the front end.. someone enters a search query.. and in the backend lets say there is a program in C++ which executes that query.
How did this interaction takes place.. if front end is written in lets say php..
I assume shell execution of program is a bad bad way to run programs.. ??
Any suggestion will be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 Ignacio 所建议的,您首先需要为您的项目设计 API。这基本上清楚地列出了您的项目将支持哪些(以及如何)查询。
您不需要执行 shell,也不需要学习 PHP。由于您的项目是使用 Python 编写的,因此您可以使用 Python Web 框架,例如 Django、Web2Py。
As suggested by Ignacio, you will first need to design API for your project. This is basically clearly laying out what (and how) queries will be supported for your project.
You don't need shell execution and neither need to learn PHP. Since your project is in Python, you can use Python Web-frameworks like Django, Web2Py.
首先要做的是为您的库开发一个 API。从那里,您可以开发使用相同 API 的多个前端,以便以多种方式呈现它。
The first thing to do is to develop an API for your library. From there you can develop multiple frontends that use the same API in order to present it multiple ways.
将用户界面逻辑与业务逻辑分离,然后在通过 HTTP(而不是控制台)接受输入的应用程序中重用业务逻辑库。 Django 是一个流行的 Web 框架,它将为您处理很多前端问题,或者您也可以如果您希望更接近裸机,请使用 CGI 之类的东西。 Python Wiki 有有关 Web 编程的部分,您可能会觉得有用。
Decouple your user interface logic from your business logic, then reuse the business logic libraries in an application that accepts input over HTTP instead of the console. Django is a popular web framework that will take care of a lot of the front end concerns for you, or you can use something like CGI if you prefer to be a bit closer to the bare metal. The Python Wiki has a section on web programming that you might find useful.