Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92542 > unrolled thread
| Started by | subhabrata.banerji@gmail.com |
|---|---|
| First post | 2015-06-12 10:52 -0700 |
| Last post | 2015-06-13 00:23 -0700 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
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
| From | subhabrata.banerji@gmail.com |
|---|---|
| Date | 2015-06-12 10:52 -0700 |
| Subject | How may I Integrate Python Code with REST |
| Message-ID | <02f1571f-a497-4b21-99b5-b39a627bb5ea@googlegroups.com> |
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.
[toc] | [next] | [standalone]
| From | sohcahtoa82@gmail.com |
|---|---|
| Date | 2015-06-12 11:59 -0700 |
| Message-ID | <1d454ab1-b589-4d0d-9d57-b00483082dcc@googlegroups.com> |
| In reply to | #92542 |
On Friday, June 12, 2015 at 10:52:30 AM UTC-7, subhabrat...@gmail.com wrote: > 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. It is slightly unclear what you're asking. REST isn't a programming language or a module or anything like that. It is a software architecture style. Flask is often used for implementing a REST interface. If you understand how to use Flask, you're basically there already.
[toc] | [prev] | [next] | [standalone]
| From | Laura Creighton <lac@openend.se> |
|---|---|
| Date | 2015-06-12 22:46 +0200 |
| Message-ID | <mailman.440.1434142009.13271.python-list@python.org> |
| In reply to | #92542 |
In a message of Fri, 12 Jun 2015 10:52:19 -0700, subhabrata.banerji@gmail.com 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
[toc] | [prev] | [next] | [standalone]
| From | subhabrata.banerji@gmail.com |
|---|---|
| Date | 2015-06-13 00:23 -0700 |
| Message-ID | <1040428a-64d0-4863-9cf0-be7baa5a0a01@googlegroups.com> |
| In reply to | #92554 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web