Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92584
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-06-13 00:23 -0700 |
| References | <02f1571f-a497-4b21-99b5-b39a627bb5ea@googlegroups.com> <mailman.440.1434142009.13271.python-list@python.org> |
| Message-ID | <1040428a-64d0-4863-9cf0-be7baa5a0a01@googlegroups.com> (permalink) |
| Subject | Re: How may I Integrate Python Code with REST |
| From | subhabrata.banerji@gmail.com |
On Saturday, June 13, 2015 at 2:17:43 AM UTC+5:30, Laura Creighton wrote:
> In a message of Fri, 12 Jun 2015 10:52:19 -0700, w
> rites:
> >Dear Group,
> >
> >I wrote a Python code. In the code there are two modules where we may insert data from outside. They are updating some training module and updating index. As a standalone code this is working fine.
> >
> >I need to port this code to REST. I tried to learn Flask. My Practice for Flask is okay. I can put,get,delete.
> >
> >But how may I proceed I am not getting much idea. I bit new in REST.
> >If any one of the esteemed members may kindly provide an idea how may I proceed?
> >
> >Regards,
> >Subhabrata Banerjee.
>
> All you need now is post. So it looks as if you have all the bits you
> need, but you don't know how to use them to design an API.
>
> See if this helps.
> http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
>
> If not, you are probably at the stage of posting code here.
> Here is my code that doesn't work.
> Here is what happens when I run it.
> This is what I wish it would do instead.
>
> Right now we don't understand what it is that you don't understand, alas.
> Code makes the problem obvious.
>
> Laura
Hi,
Thank you for your post. Yes I can PUT the data in JSON format but how to interact with the code I am thinking on that. My script snippet of Flask is as
follows,
>>> x3=requests.put('http://127.0.0.1:5000/todos/todo1', data={'task': 'We are trying to build API. API seems okay.'})
>>> x4=requests.get('http://127.0.0.1:5000/todos')
>>> x5=x4.text
>>> print x5
{
"todo1": {
"task": "We are trying to build API. API seems okay."
},
"todo2": {
"task": "Change my brakepads"
},
"todo3": {
"task": "Life is okay"
}
}
Now, as I understand it I have to work out something around this PUT.
As per my guess,
1. I should work around this put if takes data from file.
2. The data I would get thus, I have to convert this JSON data (by import json or so), into text or the format my main code understands as input.
Am I thinking fine. If not please suggest.
There is an interesting error occurs almost every other day port 5000
in
requests.get('http://127.0.0.1:5000/todos') gives error everyother day.
I have stopped firewall, consulted senior administrators of system group but no error seems there. It works suddenly and does not work suddenly,
if you suggest how to fix this issue.
I am using Python2.7+ on MS-Windows 7 Professional. I am using Microsoft Security Essentials as AntiVirus.
Regards,
Subhabrata Banerjee.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How may I Integrate Python Code with REST subhabrata.banerji@gmail.com - 2015-06-12 10:52 -0700
Re: How may I Integrate Python Code with REST sohcahtoa82@gmail.com - 2015-06-12 11:59 -0700
Re: How may I Integrate Python Code with REST Laura Creighton <lac@openend.se> - 2015-06-12 22:46 +0200
Re: How may I Integrate Python Code with REST subhabrata.banerji@gmail.com - 2015-06-13 00:23 -0700
csiph-web