The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled Python Code
Posted by: Meow | June 20, 2010 @ 4:05am
Python Code
[
Download
]
#!/usr/bin/env python from circuits.web import Server, Controller, Static ,expose from circuits import handler, Component, Debugger from circuits.web.errors import Forbidden from time import gmtime, strftime class Root(Controller): @expose("hi.html") def hi(self): fileHandle = open ( 'hi.html' ) return """<script type="text/JavaScript"> <!-- function timedRefresh(timeoutPeriod) { setTimeout("location.reload(true);",timeoutPeriod); } // --> </script><body onload="JavaScript:timedRefresh(3000);"> %s""" % fileHandle.read() fileHandle.close() def index(self, file=None,*args, **kwargs): if file is None: input = kwargs.get("input", None) if input != None: if len(input) > 0: if kwargs.get("type", None) == "write": fileHandle = open ( 'hi.html','w' ) fileHandle.write("Name: %s </br> %s" % (kwargs.get("name", None) ,input)) fileHandle.close() log = open("log", "a") log.write("At %s IP: %s , Name: %s Posted : %s \n" % ( strftime("%Y-%m-%d %H:%M:%S", gmtime()) , self.request.remote.ip ,kwargs.get("name", None) , input)) log.close() elif kwargs.get("type", None) == "append": fileHandle = open ( 'hi.html') file = fileHandle.read() fileHandle.close() fileHandle = open ( 'hi.html','w' ) fileHandle.write("Name: %s </br> %s <hr /> %s" % (kwargs.get("name", None) ,input,file)) fileHandle.close() log = open("log", "a") log.write("At %s IP: %s , Name: %s Posted : %s \n" % ( strftime("%Y-%m-%d %H:%M:%S", gmtime()) , self.request.remote.ip ,kwargs.get("name", None) , input)) log.close() return """<body><form method="POST" action="/" enctype="multipart/form-data"> Upload Image<input type="file" name="file"> <input type="submit" value="Submit"> </form><iframe src="hi.html" height = "500" width = "1000"> </iframe> <form name="input" action="" method="get"> Name:<input type="text" name="name" /></br><textarea rows="4" cols="120" name="input"> </textarea> <input type="radio" name="type" value="write" checked/> New <input type="radio" name="type" value="append" /> Add <input type="submit" value="Write" /> </form></body>""" else: filename = "./img/%s" % file.filename gee = open(filename, "w+") gee.write(file.value) return "<a href=%s >img </a>" % (filename) (Server(("0.0.0.0", 8001)) + Debugger(events=False, errors=True) + Static(docroot="img") + Root()).run()
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.43 / 8
46 Votes
http://codebin.yi.org/705
page generated in 0.00 seconds