[Tutor] Re: Dual interface app

Mike Hansen mhansen at cso.atmel.com
Thu Aug 12 20:19:18 CEST 2004


Thanks Kent.

Three modules also occurred to me, and I'll probably do just that. I 
just needed to verify if I was on the right track. What's nice about 
Python is that any program/script can become a module.

Mike

>
> Subject:
> Re: [Tutor] Dual interface app
> From:
> Kent Johnson <kent_johnson at skillsoft.com>
> Date:
> Thu, 12 Aug 2004 12:00:19 -0400
> To:
> tutor at python.org
>
> To:
> tutor at python.org
>
>
> Your solution is a good one - get the command line program working, 
> then write a separate cgi interface to the same functions. You may 
> want to have three modules - the functional module that does the work, 
> the command line interface module and the cgi module.
>
> Kent
>
> At 09:21 AM 8/12/2004 -0600, Mike Hansen wrote:
>
>> I'm thinking of making an program that can be run from the command 
>> line or through a web page. The program requires a couple of 
>> arguments. At first I thought I could check the command line 
>> arguments, and if they didn't exist check the cgi form values. 
>> However, I started running into problems when I thought this out 
>> further. What if someone runs it from a command line and forgets to 
>> add the arguments? The program will check for command line arguments, 
>> then it will check the cgi form values and assume it's being called 
>> from the web interface. The responses would have to be either in text 
>> or html.
>> One solution I thought of was to get the command line interface 
>> working in one program. Then write another program for the web 
>> interface importing the command line program and using the common 
>> functions.
>>
>> Does anyone have any other ideas? Is there a way to detect if a 
>> program is being called from the command line vs web without too much 
>> voodoo?
>>
>> Mike
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>
>


More information about the Tutor mailing list