Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31604 > unrolled thread

python scripts for web

Started bychip9munk@gmail.com
First post2012-10-18 00:18 -0700
Last post2012-10-18 09:07 -0700
Articles 17 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  python scripts for web chip9munk@gmail.com - 2012-10-18 00:18 -0700
    Re: python scripts for web Zero Piraeus <schesis@gmail.com> - 2012-10-18 03:57 -0400
      Re: python scripts for web chip9munk@gmail.com - 2012-10-18 01:10 -0700
        Re: python scripts for web Zero Piraeus <schesis@gmail.com> - 2012-10-18 04:42 -0400
          Re: python scripts for web chip9munk@gmail.com - 2012-10-18 02:22 -0700
            Re: python scripts for web Zero Piraeus <schesis@gmail.com> - 2012-10-18 06:02 -0400
              Re: python scripts for web rurpy@yahoo.com - 2012-10-18 08:14 -0700
              Re: python scripts for web chip9munk@gmail.com - 2012-10-18 09:01 -0700
            Re: python scripts for web Chris Angelico <rosuav@gmail.com> - 2012-10-18 21:02 +1100
              Re: python scripts for web chip9munk@gmail.com - 2012-10-18 09:03 -0700
                Re: python scripts for web Zero Piraeus <schesis@gmail.com> - 2012-10-18 17:09 -0400
                  Re: python scripts for web chip9munk@gmail.com - 2012-10-18 23:05 -0700
                    Re: python scripts for web Gilles <nospam@nospam.com> - 2012-10-19 12:32 +0200
                      Re: python scripts for web chip9munk@gmail.com - 2012-10-23 02:17 -0700
          Re: python scripts for web chip9munk@gmail.com - 2012-10-18 02:22 -0700
      Re: python scripts for web chip9munk@gmail.com - 2012-10-18 01:10 -0700
    Re: python scripts for web chip9munk@gmail.com - 2012-10-18 09:07 -0700

#31604 — python scripts for web

Fromchip9munk@gmail.com
Date2012-10-18 00:18 -0700
Subjectpython scripts for web
Message-ID<98b7e362-14fd-4721-84c8-ae1bc11febac@googlegroups.com>
Hello all!

Please help me start learning about this thing. Sorry for my inexperience!

Here is what I need to do: on some webpage (done in php, or any other different technology), user inputs some data, that data and the request then goes to the server where python scripts calculate something and return the result to the users end. 

Now, how do I do that server part, listening to requests, and calling python scripts?

I googled about that but I do not understand if I should do that by CGI, Flask, mod_wsgi, or any other way... I know to little about that to understand what is the way to go. :/

Please could you give me some info so that i know where I should start looking for my solution.

Thanks in advance!


[toc] | [next] | [standalone]


#31606

FromZero Piraeus <schesis@gmail.com>
Date2012-10-18 03:57 -0400
Message-ID<mailman.2409.1350547078.27098.python-list@python.org>
In reply to#31604
:

On 18 October 2012 03:18,  <chip9munk@gmail.com> wrote:
> Here is what I need to do: on some webpage (done in php, or any other
> different technology), user inputs some data, that data and the
> request then goes to the server where python scripts calculate
> something and return the result to the users end.
>
> Now, how do I do that server part, listening to requests, and calling
> python scripts?

If I understand you correctly, what you're describing here is a
webserver - i.e. Apache, nginx etc. I'm not sure why you'd want to
write one of those if you're as inexperienced as you say.

> I googled about that but I do not understand if I should do that by
> CGI, Flask, mod_wsgi, or any other way... I know to little about that
> to understand what is the way to go. :/

These are all approaches to writing the software that the webserver
hands the request off to, which is a different thing. If that's what
you really meant to ask (how to write a script that processes a
request and returns a response), then plain CGI might be the best
place to start, if you're trying to get a handle on what's going on.

Once you're happy that you understand how to build a plain CGI script,
frameworks [like Flask] can be very useful ... and Flask is both
lightweight and has good documentation, so it's not a bad choice for
learning purposes.

 -[]z.

[toc] | [prev] | [next] | [standalone]


#31607

Fromchip9munk@gmail.com
Date2012-10-18 01:10 -0700
Message-ID<e10b4aba-a725-46c4-aaa9-0035a099a9bf@googlegroups.com>
In reply to#31606
To explain, I am basically doing different algorithms and would like to make them work and be accessible as I mentioned in the example... and to add them to the functionality of a specific page... so I have experience in programming, just no experience in web development etc.. 

On Thursday, October 18, 2012 9:57:58 AM UTC+2, Zero Piraeus wrote:
> 
> If I understand you correctly, what you're describing here is a
> webserver - i.e. Apache, nginx etc. I'm not sure why you'd want to
> write one of those if you're as inexperienced as you say.
> These are all approaches to writing the software that the webserver
> hands the request off to, which is a different thing. If that's what
> you really meant to ask (how to write a script that processes a
> request and returns a response), then plain CGI might be the best
> place to start, if you're trying to get a handle on what's going on.

I understand how the lack of knowledge on my part can cause the unclarity of my question.
I will give you an example. So let us say I create two simple python scripts, one does the sum of two numbers
the other one does the multiplication. SO now I want to put these scripts on the server. Now let us say there is a web page that would like to use these scripts (do this calculation). How do I do a "program" that will listen for the requests
from the web page and call the scripts on the request?  
 
> Once you're happy that you understand how to build a plain CGI script,
> frameworks [like Flask] can be very useful ... and Flask is both
> lightweight and has good documentation, so it's not a bad choice for
> learning purposes.

all the tutorials about flask are dealing wit creating the whole webpage in python. I do not need to do that, I just need a service on the servers end.. is flask still the way to go? Also flask does not support Python 3.x jet, would using cherryPy be a good idea?

Thank you for the answers! 

[toc] | [prev] | [next] | [standalone]


#31610

FromZero Piraeus <schesis@gmail.com>
Date2012-10-18 04:42 -0400
Message-ID<mailman.2412.1350549775.27098.python-list@python.org>
In reply to#31607
:

On 18 October 2012 04:10,  <chip9munk@gmail.com> wrote:
> I will give you an example. So let us say I create two simple python
> scripts, one does the sum of two numbers
> the other one does the multiplication. SO now I want to put these
> scripts on the server. Now let us say there is a web page that would
> like to use these scripts (do this calculation). How do I do a
> "program" that will listen for the requests
> from the web page and call the scripts on the request?

That is exactly what a webserver does. Is there some reason you don't
want to use e.g. Apache to handle the requests?

 -[]z.

[toc] | [prev] | [next] | [standalone]


#31613

Fromchip9munk@gmail.com
Date2012-10-18 02:22 -0700
Message-ID<809c86c5-26a0-4f4a-bce7-ad8f63efa763@googlegroups.com>
In reply to#31610
On Thursday, October 18, 2012 10:42:56 AM UTC+2, Zero Piraeus wrote:
> That is exactly what a webserver does. Is there some reason you don't
> want to use e.g. Apache to handle the requests?

no reason at all. so i guess the solution is much easier then I have anticipated.
So i guess in that case i do not need cgi or anything?

Thank you for clearing that out!

[toc] | [prev] | [next] | [standalone]


#31620

FromZero Piraeus <schesis@gmail.com>
Date2012-10-18 06:02 -0400
Message-ID<mailman.2418.1350554559.27098.python-list@python.org>
In reply to#31613
:

On 18 October 2012 05:22,  <chip9munk@gmail.com> wrote:
> So i guess in that case i do not need cgi or anything?

Assuming your scripts accept the request as sent and return an
appropriate response, they are CGI scripts (unless there's some
wrinkle in the precise definition of CGI that escapes me right now).

> Thank you for clearing that out!

No bother :-)

By the way: are you using Google Groups? It's just that I'm led to
understand that it's recently started to misbehave [more than it used
to], and your replies are addressed to both
<comp.lang.python@googlegroups.com> and <python-list@python.org>,
which is redundant.

Or perhaps it always did that, and I've never noticed before ...

 -[]z.

[toc] | [prev] | [next] | [standalone]


#31651

Fromrurpy@yahoo.com
Date2012-10-18 08:14 -0700
Message-ID<ce2b1fcf-9cd0-4647-9309-be4a49eece2f@googlegroups.com>
In reply to#31620
On 10/18/2012 04:02 AM, Zero Piraeus wrote:> On 18 October 2012 05:22,  <chip9munk@gmail.com> wrote:
>>[...]
> By the way: are you using Google Groups? It's just that I'm led to
> understand that it's recently started to misbehave [more than it used
> to], and your replies are addressed to both
> <comp.lang.python@googlegroups.com> and <python-list@python.org>,
> which is redundant.

When you post from Google Groups you will sometimes
see a checkbox above the edit window that is a cc to
the python mailing list (<python-list@python.org>) 
which is checked by default.  

If you uncheck that, you'll stop the double posting.

[toc] | [prev] | [next] | [standalone]


#31656

Fromchip9munk@gmail.com
Date2012-10-18 09:01 -0700
Message-ID<8be7a481-c5c7-4bac-8470-32824f9ad40c@googlegroups.com>
In reply to#31620
On Thursday, October 18, 2012 12:02:40 PM UTC+2, Zero Piraeus wrote:

> Assuming your scripts accept the request as sent and return an
> appropriate response, they are CGI scripts (unless there's some
> wrinkle in the precise definition of CGI that escapes me right now).

yes, they are, but, I came under the impression that it is not the most elegant/fast way to do it... shouldn't the mod_wsgi be a better strategy?
or am i mixing these therms?

[toc] | [prev] | [next] | [standalone]


#31621

FromChris Angelico <rosuav@gmail.com>
Date2012-10-18 21:02 +1100
Message-ID<mailman.2419.1350554581.27098.python-list@python.org>
In reply to#31613
On Thu, Oct 18, 2012 at 8:22 PM,  <chip9munk@gmail.com> wrote:
> On Thursday, October 18, 2012 10:42:56 AM UTC+2, Zero Piraeus wrote:
>> That is exactly what a webserver does. Is there some reason you don't
>> want to use e.g. Apache to handle the requests?
>
> no reason at all. so i guess the solution is much easier then I have anticipated.
> So i guess in that case i do not need cgi or anything?
>
> Thank you for clearing that out!

CGI is a protocol between Apache and your script. What you want to do
is set up Apache to call your CGI scripts.

BTW, you don't need to send to both comp.lang.python and python-list -
they mirror each other.

ChrisA

[toc] | [prev] | [next] | [standalone]


#31657

Fromchip9munk@gmail.com
Date2012-10-18 09:03 -0700
Message-ID<866debf5-4b07-4b93-b785-442b1b14e2e5@googlegroups.com>
In reply to#31621
thank you for the answer!

On Thursday, October 18, 2012 12:03:02 PM UTC+2, Chris Angelico wrote:
> CGI is a protocol between Apache and your script. What you want to do
> is set up Apache to call your CGI scripts.



yes, but as I have just answered to Zero, is using mod_wsgi a better strategy?

[toc] | [prev] | [next] | [standalone]


#31685

FromZero Piraeus <schesis@gmail.com>
Date2012-10-18 17:09 -0400
Message-ID<mailman.2475.1350594610.27098.python-list@python.org>
In reply to#31657
:

On 18 October 2012 12:03,  <chip9munk@gmail.com> wrote:
> yes, but as I have just answered to Zero, is using mod_wsgi a better strategy?

WSGI would enable you to write a persistent application that sits
around waiting for requests and returns responses for them as and
when, as opposed to a simple CGI script that gets started each time a
request comes in, and terminates once it's returned the response.

So it's really about startup time - if your scripts are just doing
something simple and quick, WSGI is likely overkill.

 -[]z.

[toc] | [prev] | [next] | [standalone]


#31713

Fromchip9munk@gmail.com
Date2012-10-18 23:05 -0700
Message-ID<001d1ee0-80d6-44f8-aa38-85d8e18f925b@googlegroups.com>
In reply to#31685
On Thursday, October 18, 2012 11:10:45 PM UTC+2, Zero Piraeus wrote:
> WSGI would enable you to write a persistent application that sits
> around waiting for requests and returns responses for them as and
> when, as opposed to a simple CGI script that gets started each time a
> request comes in, and terminates once it's returned the response.

ok I see, you have made it very clear for me now!
 
> So it's really about startup time - if your scripts are just doing
> something simple and quick, WSGI is likely overkill.

these scripts will do a lot of calculation on a big dataset, and it is possible that there will be many requests in a short period of time.
So I guess the WSGI is a better solution.

Thank you and the others very much, you have saved me a lot of time!

Cheers! 

[toc] | [prev] | [next] | [standalone]


#31735

FromGilles <nospam@nospam.com>
Date2012-10-19 12:32 +0200
Message-ID<20b28813ug83l2odd6s1hr6d03pf1rs8u6@4ax.com>
In reply to#31713
On Thu, 18 Oct 2012 23:05:48 -0700 (PDT), chip9munk@gmail.com wrote:
>these scripts will do a lot of calculation on a big dataset, and it is possible that there will be many requests in a short period of time.

In that case, are you sure a web script is a good idea? If you're
thinking web to make it easy for people to upload data, click on a
button, and get the results back, you might want to write the UI in
Python but write the number crunching part in a compiled language.

[toc] | [prev] | [next] | [standalone]


#31923

Fromchip9munk@gmail.com
Date2012-10-23 02:17 -0700
Message-ID<34e4f2c8-c4c6-4b53-89a8-05b8e2fc8fb6@googlegroups.com>
In reply to#31735
On Friday, October 19, 2012 12:32:48 PM UTC+2, Gilles wrote:
> In that case, are you sure a web script is a good idea? If you're
> thinking web to make it easy for people to upload data, click on a
> button, and get the results back, you might want to write the UI in
> Python but write the number crunching part in a compiled language.

well actually I would like to separate the web interface with this API...
that is why I would like to work on the server side and not think about the 
interface side.


[toc] | [prev] | [next] | [standalone]


#31614

Fromchip9munk@gmail.com
Date2012-10-18 02:22 -0700
Message-ID<mailman.2414.1350552135.27098.python-list@python.org>
In reply to#31610
On Thursday, October 18, 2012 10:42:56 AM UTC+2, Zero Piraeus wrote:
> That is exactly what a webserver does. Is there some reason you don't
> want to use e.g. Apache to handle the requests?

no reason at all. so i guess the solution is much easier then I have anticipated.
So i guess in that case i do not need cgi or anything?

Thank you for clearing that out!

[toc] | [prev] | [next] | [standalone]


#31608

Fromchip9munk@gmail.com
Date2012-10-18 01:10 -0700
Message-ID<mailman.2410.1350547860.27098.python-list@python.org>
In reply to#31606
To explain, I am basically doing different algorithms and would like to make them work and be accessible as I mentioned in the example... and to add them to the functionality of a specific page... so I have experience in programming, just no experience in web development etc.. 

On Thursday, October 18, 2012 9:57:58 AM UTC+2, Zero Piraeus wrote:
> 
> If I understand you correctly, what you're describing here is a
> webserver - i.e. Apache, nginx etc. I'm not sure why you'd want to
> write one of those if you're as inexperienced as you say.
> These are all approaches to writing the software that the webserver
> hands the request off to, which is a different thing. If that's what
> you really meant to ask (how to write a script that processes a
> request and returns a response), then plain CGI might be the best
> place to start, if you're trying to get a handle on what's going on.

I understand how the lack of knowledge on my part can cause the unclarity of my question.
I will give you an example. So let us say I create two simple python scripts, one does the sum of two numbers
the other one does the multiplication. SO now I want to put these scripts on the server. Now let us say there is a web page that would like to use these scripts (do this calculation). How do I do a "program" that will listen for the requests
from the web page and call the scripts on the request?  
 
> Once you're happy that you understand how to build a plain CGI script,
> frameworks [like Flask] can be very useful ... and Flask is both
> lightweight and has good documentation, so it's not a bad choice for
> learning purposes.

all the tutorials about flask are dealing wit creating the whole webpage in python. I do not need to do that, I just need a service on the servers end.. is flask still the way to go? Also flask does not support Python 3.x jet, would using cherryPy be a good idea?

Thank you for the answers! 

[toc] | [prev] | [next] | [standalone]


#31658

Fromchip9munk@gmail.com
Date2012-10-18 09:07 -0700
Message-ID<8f015d66-73e6-4d70-996a-8f35743e9d84@googlegroups.com>
In reply to#31604
thank you guys for pointing the double posting issue out, I am having some issues with the news server i am using, so I am doing this via google.groups at the time! :)

i think i managed to fix it

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web