REST API framwork,与我的Python程序,而不是作品数据库 [英] REST API framwork that works with my python program instead of Database

查看:131
本文介绍了REST API framwork,与我的Python程序,而不是作品数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个非常简单的REST API。我发现EVE框架非常有前途,我想,而不是使用数据库。导入我的.py code和执行它和返回字符串。它应该是这样的:

I wanted to create a very simple REST API. I found EVE Framework very promising and I want to instead of using a Database. import my .py code and execute it and return the string. It should be something like:

http://myipserver:5000/myprogram.py?string=xxx

的'xxx'是我找得到,然后用我的.py code评估它的字符串。

where 'xxx' is the string I'm looking to get and then evaluate it using my .py code.

这将会是巨大的,如果有一种方法,使其与EVE或任何其他框架。我运行Nginx的。

It'd be great if there's a way to make it work with EVE or any other Framework. I'm running Nginx.

注意:我的老问题在这里(请点击这里获取更多信息),我明白我应该从谷歌搜索谷歌搜索和我必须将它转化成PHP或在Linux上运行,因此另一种编程语言,我选择Python的,因为我已经熟悉它。现在我要运行它作为REST API,而不是仅仅插座/ TCP简单的服务器。

NB: my old question here ( please click here for more info) , I understand that I should from Googling and Googling that I have to convert it to PHP or another programming language that runs on Linux so, I chose Python since I'm already familiar with it. and now I want to run it as REST API instead of just Socket/TCP simple server.

推荐答案

如果我得到你的问题的权利,是的,你可以在除夕REST API的顶部安装定制的端点。不长前,我写这个的文章,检查出来对于细节,但它确实可以归结为做这样的事情:

If I got your question right yes, you can mount custom endpoints on top of a Eve REST API. Not a long ago I wrote an article about this, check it out for the details, but it really boils down to doing something like this:

from eve import Eve
app = Eve()

@app.route('/hello')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

这仅仅是利用标准瓶的特点。然后,您可以访问 /你好端点在您的功能将尽一切需要做的。

This is just leveraging the standard Flask features. Then you can access the /hello endpoint where your function will do whatever it needs to do.

这篇关于REST API framwork,与我的Python程序,而不是作品数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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