User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 402,476 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,918 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums

stuck in cgi image stuff

Join Date: Jun 2005
Posts: 39
Reputation: nephish is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nephish nephish is offline Offline
Light Poster

Re: stuck in cgi image stuff

  #3  
Jun 14th, 2005
ok, here ya go
#!/usr/bin/python
import os
import cgi
import cgitb; cgitb.enable()
from time import gmtime, strftime

the_time = strftime("%A, %B %d, %Y") #Get a TimeStamp

#This script takes data from ViewRecords.py and opens and views the 
#Selected text file
#some bug some where

form = cgi.FieldStorage()
DataRecord = form['DataTime'].value
Customer = form['CustName'].value 

# Set up the html stuff
reshtml = """Content-Type: text/html\n
<html>
 <head><title>Customer Data</title></head>
<body>
"""


print reshtml
print '<big><span style="font-weight: bold;">Watkins Crop Consulting</span>&nbsp;'
print '</big>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
print '&nbsp;&nbsp;<big>'+the_time+'</big>'
print '<br>'
print "1915 Cherokee <br>"
print "Dalhart, Tx 79022 <br>   333-5943&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<H2>"+Customer+"</H2>"


fileHandle = open("/var/www/stretch/web_root/SidCrops/"+Customer+"/"+DataRecord, "r")
lineList = fileHandle.readlines()
fileHandle.close()
Line_Iters = len(lineList)/7 #number of lines in the file divided by 7 (how many fields there are)


Iterations = 0 #represents the number of times the following while loop will run
NextStep = 0 #Increments to the next line of the file 
while Iterations < Line_Iters:
	print '<meta'
 	print 'content="text/html; charset=ISO-8859-1" http-equiv="content-type">'
  	print '<title></title>'
	print '</head>'
	print '<body>'
	print '<table style="text-align: left; width: 100%;"'
 	print 'border="0" cellpadding="0" cellspacing="0">'
  	print '<tbody>'
   	print '<tr>'
     	print '<td><img'
 	print 'style="width: 150px; height: 150px;" alt="circle"'
	print 'src="http://stretchweb.org/"'+lineList[NextStep]+".gif"+"></td>'
      	print '<td>'
	NextStep = NextStep + 1
	print "<span style='font-weight: bold;'>Field -</span>&nbsp;&nbsp;&nbsp;&nbsp; "+lineList[NextStep]+"	"
	NextStep = NextStep + 1
	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
	print "<span style='font-weight: bold;'>Crop -</span>&nbsp;&nbsp;&nbsp;&nbsp; "+lineList[NextStep]+"	"
	NextStep = NextStep + 1
	print "<span style='font-weight: bold;'>GS -</span>&nbsp;&nbsp;&nbsp;&nbsp; "+lineList[NextStep]+"	"
	NextStep = NextStep + 1
	print '<br>'
	print '<br>'
	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
	print "<span style='font-weight: bold;'>Water -</span>&nbsp;&nbsp;&nbsp;&nbsp; "+lineList[NextStep]+"	"
	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
	print "<br>"
	print "<br>"
	NextStep = NextStep + 1
	print "<span style='font-weight: bold;'>Remarks -</span>&nbsp;&nbsp;&nbsp;&nbsp; "+lineList[NextStep]+"	"
	print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
	NextStep = NextStep + 1
	print "<br>"
	print "<br>"
	print "<span style='font-weight: bold;'>Treatments -</span>&nbsp;&nbsp; "+lineList[NextStep]+"	"
	print "<br>"
	NextStep = NextStep + 1
	Iterations = Iterations + 1
	print "<br>"
	print "<br>"
	print '</td>'
    	print '</tr>'
  	print '</tbody>'
	print '</table>'
	print '<br>'
	print '<br>'
	print '<br>'
	print '<br>'

	
print "<br>"
print  "</body>"
print "</html>"

and a sample of the text file lines
circle1.gif
line
of
text
will
always
be a factor of seven
circle2.giff
because
the .py file
that writes
the text from the form
writes seven lines at
a time

hope this helps...

by the way, if i dont use a variable but just print image="circle.giff"
it all works fine

thanks
Reply With Quote  
All times are GMT -4. The time now is 4:35 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC