def taled(): from planes.lazy import\ serve,\ PathService,\ ResponseService engine = Engine() service = TaleService(engine) service = PathService(paths = {'session': service}) service = ResponseService(service) serve(service, port = 2380, debug = True, engine = engine)
# Run and browse to http://localhost:8080 from planes.lazy import serve, WidgetService serve(WidgetService(10), port = 8080)
from planes.lazy import serve, HostService, ChatService serve( service = HostService(ChatService()), port = 8080, debug = True, )
from planes.lazy import ( serve, WidgetService, FunctionService, AuthShadowService, AuthShadowSelfService, HostService ) def g(): raise Exception("hi") def f(): g() a = 10 serve( HostService( contents = { 'a': WidgetService(a), 'f': FunctionService(f), 'g': FunctionService(g), 'auth_shadow': AuthShadowService(WidgetService(a)), 'auth_shadow_self': AuthShadowSelfService(WidgetService(a)), }, ), port = 4343, ssl = True, interface = '', debug = True, )
}; request.open( 'POST', 'http://localhost:8080/echo', true ); request.setRequestHeader('Content-type', 'text/plain'); request.send( 'This is a sentence that was sent in ' + 'the POST content of an AJAX request and ' + 'returned by an EchoService.' ); //''' ), ) ) serve( HostService( ClientService(), contents = { 'echo': EchoService(), }, ), port = 8080, debug = True, )
from planes.lazy import JsonChatService, ResponseService, serve serve(ResponseService(JsonChatService()), port = 8080)
from planes.lazy import DhtService, PathService, StandardService, serve from sys import argv from random import choice nodes = [] for n in range(20): node = DhtService('/%s' % n) if len(nodes): node.join(choice(nodes)[1]) nodes.append([n, node]) nodes[0][1].data['hi'] = 'world' serve( StandardService( PathService(paths = dict( ('%s' % n, node) for n, node in nodes )) ), port = int(argv[1]), debug = True )
from planes.lazy import serve, BaseService, LogService class Service(BaseService): def __call__(self, kit): request = kit.request request.setResponseCode(200, "OK") request.setHeader("content-type", "text/plain") path = request.path[1:] who = path and path or 'World' request.write("Hello, %s!\n" % who) request.finish() 1 / 0 serve(port = 8080, service = LogService(Service()))
serve( PathService( host = host, contents = { 'adhoc': host, }, service = WidgetService( tags.div( MagnetWidget(string) for string in ( 'a', 'a', 'the', 'the', 'and', 'or', 'with', 'woman', 'man', 'puppy', 'unicorn', 'hopped', 'killed', 'bludgeoned', 'eviscerated', 'in bed', )[::-1] ), ), ), port = 8080, debug = True, )
# Run and browse to http://localhost:8080 from planes.lazy import ( serve, PathService, HostService, WidgetService, MobileWidget ) host = HostService() serve( PathService( service = WidgetService(MobileWidget(dir())), host = host, contents = {'adhoc': host,}, ), port = 8080, debug = True, )
from planes.lazy import StandardService, PathService, serve from planes.response import Redirect, Response serve( port=8080, service=StandardService(PathService(service=Redirect("redirect"), paths={"redirect": Response("Hello, World!")})), )
serve( PathService( host=host, contents={"adhoc": host}, service=WidgetService( tags.div( MobileWidget(string) for string in ( "a", "a", "the", "the", "and", "or", "with", "woman", "man", "puppy", "unicorn", "hopped", "killed", "bludgeoned", "eviscerated", "in bed", )[::-1] ) ), ), port=8080, debug=True, )
) from planes.python.html import tags host = HostService() serve( service = HostService( contents = { 'widget': WidgetService(ShellWidget()), 'service': ShellService(), 'both': ShellService( body = tags.div( ShellWidget(), style = ''' position: fixed; top: 10px; right: 10px; bottom: 10px; width: 25%; ''' ) ), '.host': host, }, host = host, ), port = 8080, debug = True, )
from planes.lazy import serve, RegexService, BaseService class Service(BaseService): def respond(self, request): request.setResponseCode(200, "OK") request.setHeader("content-type", "text/plain") request.write("Hello, World!\n") request.finish() serve(port=8080, service=RegexService(((r"^hi", Service()),)))
#!/usr/bin/env python from planes.lazy import serve, Service, FunctionService, StandardService, SslService, Response @StandardService @FunctionService def service(kit): return Response( content_type = 'text/plain', content = 'Hello, World!', ) serve(services = ( Service(service, port = 8080), SslService(service, port = 4343) ))
host = HostService() serve( PathService( host = host, contents = {'.adhoc': host,}, service = WidgetService( tags.div( VerticalSplitWidget( tags.div( tags.h1('Powers of Two'), Widget(tuple(2 ** n for n in range(200))), style = 'padding: 10px;' ), tags.div( tags.h1( ClockWidget(), ), style = ''' text-align: center; padding: 10px; ''', ), ) ) ), ), port = 8080, debug = True, )
from planes.lazy import ( serve, PyshService, HostService, AuthShadowSelfService ) serve( service = AuthShadowSelfService(HostService(PyshService())), port = 4343, ssl = True, debug = True, )
) def __html_repr__(self, kit): tags = kit.tags host = kit.host id = kit.next_id() session_url = host( object = self, expires = True, service = FunctionService(time.asctime), ) print session_url return tags.div( tags.div('', id = id), Javascript( '''clock.init(%s, %s, %s)''' % ( repr(id), repr(session_url), repr({'pollingInterval': 1500, 'debug': 1}), ), {'clock': ClockWidget.javascript}, ), ) serve( HostService(WidgetService(MobileWidget(ClockWidget()))), port = 8080, debug = True, )
from planes.python.xml.tags import tags from planes.lazy import JsonReaderService, PathService, ResponseService, LogService, serve from planes.response import Page service = PathService() @service.decorate("json") @JsonReaderService @ResponseService def json_service(kit, json): return Page(title="Page", body_content=(tags.h1("Title"), tags.p("Content"))) service = ResponseService(service) service = LogService(service) serve(port=8080, service=service)
from planes.lazy import serve, HostService, WidgetService from planes.javascript import Javascript, javascripts serve( service = HostService( WidgetService(Javascript('', {'jsTest': javascripts.javascript_test})), ), port = 8080, )
from planes.lazy import serve, AdhocKitService, AdhocService, PathService from planes.response import Redirect, Response, ResponseService, NotFound adhoc = AdhocService('/adhoc') @AdhocKitService(adhoc = adhoc) def service(kit): def adhoc(kit): return Response("Hello, World!") if kit.path == '/': path = kit.serve(adhoc, expires = True) return Redirect(path) else: return NotFound(kit.full_path) service = PathService( paths = {'adhoc': adhoc,}, next_service = service, ) service = ResponseService(service) serve(service, port = 8080)
from planes.lazy import serve, function_service as service, PathService from planes.page import Redirect @service() def redirect(self, *args): return Redirect(self.base_path + '/hello' + self.path) @service(content_type = 'text/plain') def hello(self, who = 'World'): return 'Hello, %s!' % who serve( port = 8080, interface = '', service = PathService( contents = { 'hello': hello }, next_service = redirect, ), )