Difference between revisions of "LSL HTTP server/examples/kellys stupid web status updater"
< LSL HTTP server | examples
Jump to navigation
Jump to search
Kelly Linden (talk | contribs) (Created page with '== What == This is a dead stupid, insecure and simple system that will update the floating text above a prim according to what is entered in the web form. Uses html forms, pytho...') |
Kelly Linden (talk | contribs) |
||
Line 20: | Line 20: | ||
* URL: if found will write the value to a file | * URL: if found will write the value to a file | ||
* Message: if found will read from the file and send the contents to the url in the file | * Message: if found will read from the file and send the contents to the url in the file | ||
Bugs: | |||
* Entering no text in the form will cause the cgi to error. | |||
<python> | <python> | ||
</ | #!/usr/bin/python | ||
import cgi, urllib2, urllib | |||
import cgitb | |||
cgitb.enable() | |||
file_name = "my_url" | |||
form = cgi.FieldStorage() | |||
if (form.has_key("Message")): | |||
print "Status: 302 Moved" | |||
print "Location: http://www.myurl.com/path/to/form" | |||
print | |||
f = open(file_name,'r') | |||
base_url = f.read() | |||
message = form["Message"].value | |||
args = "?Message=%s" % urllib.quote(message) | |||
response = urllib2.urlopen(base_url + args) | |||
if (form.has_key("URL")): | |||
print form["URL"].value | |||
f = open(file_name,'w') | |||
f.write(form["URL"].value) | |||
print "Content-Type: text/html" | |||
print | |||
print "OK" | |||
</python> | |||
== status.lsl == | == status.lsl == | ||
<lsl> | <lsl> |
Revision as of 11:54, 21 July 2009
What
This is a dead stupid, insecure and simple system that will update the floating text above a prim according to what is entered in the web form. Uses html forms, python and LSL.
index.html
A simple webform that sends the input to our cgi. <html4strict><html>
<body>
<form ACTION="cgi-bin/post.cgi" METHOD="GET"> <textarea name="Message" rows="5" cols="40" onfocus="this.value=; this.onfocus=null;">Enter your status update here.</textarea>
<INPUT TYPE="submit" title="FOO"> </form>
<body>
</html></html4strict>
post.cgi
A simple CGI that takes GETs and looks for two parameters:
- URL: if found will write the value to a file
- Message: if found will read from the file and send the contents to the url in the file
Bugs:
- Entering no text in the form will cause the cgi to error.
<python>
- !/usr/bin/python
import cgi, urllib2, urllib import cgitb cgitb.enable()
file_name = "my_url"
form = cgi.FieldStorage() if (form.has_key("Message")):
print "Status: 302 Moved" print "Location: http://www.myurl.com/path/to/form" print
f = open(file_name,'r') base_url = f.read() message = form["Message"].value args = "?Message=%s" % urllib.quote(message) response = urllib2.urlopen(base_url + args)
if (form.has_key("URL")):
print form["URL"].value f = open(file_name,'w') f.write(form["URL"].value) print "Content-Type: text/html" print print "OK"
</python>
status.lsl
<lsl> default {
state_entry() { }
} </lsl>