Beispiel #1
0
def _main():
    from wsgiref.simple_server import make_server
    httpd = make_server(
        '', 5080, restlite.router([
            (r'GET,PUT,POST,DELETE /rest', wsgiapp),
        ]))
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
Beispiel #2
0
    def start(self):
        from wsgiref.simple_server import make_server
        httpd = make_server(
            '',
            config.getSettings("server")["port"],
            restlite.router(self.routes)
        )

        try:
            httpd.serve_forever()
        except KeyboardInterrupt:
            pass
Beispiel #3
0
    def start(self):
        """
        Build the actual server and set it running.

        This will use the setup performed by any of the other class methods,
        it also takes into account any :mod:`config` values set.

        """

        from wsgiref.simple_server import make_server
        httpd = make_server(
            '',
            config.getSettings("server")["port"],
            restlite.router(self.routes)
        )

        try:
            httpd.serve_forever()
        except KeyboardInterrupt:
            pass
Beispiel #4
0
    except:
        dobj = "Nombre=" + nombre + ",Altura=0,Volumen(cm3)=0,Densidad(g/cm3)=0"
        #raise restlite.Status, '400 Error retrieving data'
        return dobj


routes = [
    (r'GET /up', up),
    (r'GET /down', down),
    (r'GET /slow', slow),
    (r'GET /image', image),
    (r'GET /load', load),
    (r'GET /level', level),
    (r'GET /plotload', plotload),
    (r'GET /plotlevel', plotlevel),
    (r'GET /object', object),
    (r'GET /liquid', liquid),
]

import restlite

from wsgiref.simple_server import make_server

httpd = make_server('', 2001, restlite.router(routes))

try:
    prexecute()
    httpd.serve_forever()
except KeyboardInterrupt:
    pass
Beispiel #5
0
    (r'GET,POST /rest/(?P<path>.*)/delete$', 'DELETE,DELETE /rest/%(path)s'),
    (r'POST /rest/(?P<path>.*)/put$', 'PUT /rest/%(path)s'),
    (r'GET,PUT,POST,DELETE /rest', restapi.wsgiapp),
    
    # web files
    (r'GET /(?P<lang>(hi_IN)|(en_US))/(?P<path>.*)$', 'GET /%(path)s?lang=%(lang)s'), 
    (r'GET /(?P<path>((favicon.ico)|(crossdomain.xml)|(embed)|(flvs)|(users)|(download)|(cgi))(/.*)?)', 'GET /www/%(path)s'),
    (r'GET /www/embed$', 'GET /www/embed/index.swf'),
    (r'GET /www/cgi', cgiscript),
    (r'GET /www', webfile),
    (r'POST /', postscript),
    (r'GET /index.html$', 'GET /'),
    (r'GET /(?P<query>\?.*)?$', indexfile),
    (r'GET /(?P<path>[^\?]+)(?P<query>\?.*)?$', 'GET /%(query)s', 'TARGET=%(path)s', indexfile)
]
webserver = restlite.router(_routes)
        
#----------------------------
# FLASH SERVER IMPLEMENTATION
#----------------------------

class Record(rtmp.App):
    def __init__(self):
        rtmp.App.__init__(self)
    
class Call(rtmp.App):
    def __init__(self):
        rtmp.App.__init__(self)
        self.clientId = 0 # unique client identifier for each client in this call application
    def onConnect(self, client, *args):
        result = rtmp.App.onConnect(self, client, *args)
Beispiel #6
0
    (r'GET,PUT,POST /(?P<type>((json)))/(?P<path>.*)', 'GET,PUT,POST /%(path)s', 'ACCEPT=application/%(type)s'),
    (r'GET /config\?directory=(?P<directory>.*)', 'PUT /config', 'CONTENT_TYPE=text/plain', 'BODY=%(directory)s', config),
    (r'GET,PUT,POST /config$', 'GET,PUT,PUT /config', config),
    (r'GET /files', files),
    (r'GET /file', file),
    (r'GET /users', users),
    (r'GET /private/', private)
]        

# launch the server on port 8000
    
if __name__ == '__main__':
    import sys
    from wsgiref.simple_server import make_server
    
    httpd = make_server('', 8000, restlite.router(routes))
    
    # if unit test is desired, perform unit testing
    if len(sys.argv) > 1 and sys.argv[1] == '--unittest':
        import urllib2, cookielib
        password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
        top_level_url = "localhost:8000"
        password_mgr.add_password(None, top_level_url, "*****@*****.**", "somepass")
        cj = cookielib.CookieJar()
        urllib2.install_opener(urllib2.build_opener(urllib2.HTTPBasicAuthHandler(password_mgr), urllib2.HTTPCookieProcessor(cj)))
        
        def urlopen(url, prefix="http://localhost:8000"):
            try: return urllib2.urlopen(prefix + url).read()
            except: return sys.exc_info()[1]
            
        def test():
Beispiel #7
0
liste_jurons=open('jurons.txt','r').readlines()
from random import randint

def juron():
    return liste_jurons[randint(0,len(liste_jurons))]

def jurons(n):
    html = '''<html><body>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <h1 align="center">Les %d jurons demand&eacute;s :</h1>
                   <br><br> %s </body/</html>
'''
    s = '\n'.join(['<br>'+liste_jurons[randint(0,len(liste_jurons))] for i in range(n)])
    return html % (n,s)


def portrait_handler(env, start_response):
    start_response('200 OK', [('Content-Type', 'image/jpeg')])
    return open('haddock.jpg').read()



routes = [
 (r'GET /juron$', juron_handler),
 (r'GET /jurons\?nombre=(?P<nombre>\d*)', jurons_handler),
 (r'GET /portrait$',  portrait_handler)
]


httpd = wsgiref.simple_server.make_server('193.55.63.80', 8889, restlite.router(routes))
httpd.serve_forever()
Beispiel #8
0
        (r'GET /(?P<path>.*)', do_message),
    ]

# Find the data in the home directory
if sys.platform == 'win32':
    import _winreg
    home_config = _winreg.ExpandEnvironmentStrings(u'%APPDATA%\\Platane\\')
else:
    home_config = os.path.expanduser("~" + getpass.getuser()) + '/.platane/'
root = None
home_root = home_config + "root"
if os.path.exists(home_root):
    root = home_root
    model.root = root

application = restlite.router(routes)

# Starts a standalone instance
if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    console_handler = logging.StreamHandler(sys.stdout)
    formatter = logging.Formatter(
        "%(asctime)s %(levelname)s [%(name)s] %(message)s")
    console_handler.setFormatter(formatter)
    logging.getLogger().addHandler(console_handler)

    opt_parser = optparse.OptionParser()
    opt_parser.add_option("-r",
                          "--root",
                          dest="root",
                          help="Root for data",
Beispiel #9
0
	                        #return request.response({ 'model': params['model'], 'jobid': taskid, 'image_id': int(imglist[i]), 'user': int(params['user']), 'version': int(params['version']), 'batch': 'yes' })
			else:
				return 'Error'
		return request.response({ 'model': params['model'], 'batchjobid': batchid, 'image_id': imglist, 'user': int(params['user']), 'version': int(params['version']), 'batch': 'yes' })
	return locals()


# List of all the possible routes
routes = [ 
    (r'GET /servers/', 'GET /servers/', listservers),
    (r'GET /log/', 'GET /log/', getlog),
    (r'GET /jobs/', 'GET /jobs/', joblist),
    (r'GET /jobsdone/', 'GET /jobsdone/', jobsdonef),
    (r'POST /jobs/(?P<task>.*)', 'POST /jobs/%(task)s', 'ACCEPT=application/json', joblist),
    (r'POST /batchjobs/(?P<task>.*)', 'POST /batchjobs/%(task)s', 'ACCEPT=application/json', batchjoblist),
    (r'POST /kill/(?P<task>.*)', 'POST /kill/%(task)s', 'ACCEPT=application/json', killjob),
    (r'POST /killbatch/(?P<task>.*)', 'POST /killbatch/%(task)s', 'ACCEPT=application/json', killbatch),
    (r'GET /alljobs/', 'GET /alljobs/', alljobs),
    (r'POST /alljobs/(?P<task>.*)', 'POST /alljobs/%(task)s', alljobs),
    (r'POST /removejob/(?P<task>.*)', 'POST /removejob/%(task)s', removejob),
    (r'GET /status/', status)
]

if __name__ == '__main__':
    import sys
    from wsgiref.simple_server import make_server
    httpd = make_server('', port, restlite.router(routes))
    try: httpd.serve_forever()
    except KeyboardInterrupt: pass

Beispiel #10
0
def _main():
    from wsgiref.simple_server import make_server
    httpd = make_server('', 5080, restlite.router([(r'GET,PUT,POST,DELETE /rest', wsgiapp),]))
    try: httpd.serve_forever()
    except KeyboardInterrupt: pass
Beispiel #11
0
users = {}

routes = [
    # rest api requests
    (r'GET,PUT,POST,DELETE /(?P<type>((xml)|(plain)))/(?P<path>.*)$', 'GET,PUT,POST,DELETE /%(path)s', 'ACCEPT=text/%(type)s', 'CONTENT_TYPE=text/%(type)s'),
    (r'GET,PUT,POST,DELETE /(?P<type>(json))/(?P<path>.*)$', 'GET,PUT,POST,DELETE /%(path)s', 'ACCEPT=application/%(type)s', 'CONTENT_TYPE=application/%(type)s'),
    # for browser convenience use POST /.../put for PUT and GET /.../delete DELETE
    (r'GET,POST /(?P<path>.*)/delete$', 'DELETE,DELETE /%(path)s'),
    (r'POST /(?P<path>.*)/put$', 'PUT /%(path)s'),
    
    # user data access at /rest/user
    (r'GET,PUT,POST,DELETE /user', restdata.bind(data, users)),
]

# the top level application to represent URL prefix /rest
wsgiapp = restlite.router(routes)

def _main():
    from wsgiref.simple_server import make_server
    httpd = make_server('', 5080, restlite.router([(r'GET,PUT,POST,DELETE /rest', wsgiapp),]))
    try: httpd.serve_forever()
    except KeyboardInterrupt: pass
    
def _unittest():
    import thread
    import urllib2, cookielib
    
    def adduser(user, password):
        global data, users
        data[user] = {'_access': 'drwx--x--x', '_owner': user}
        users[user] = restdata.hash(user, 'localhost', password)
    """Returns resume text"""

    start_response('200 OK', [('Content-Type', 'text/ascii')])
    try:
        with open('Darin_Plutchok_Resume_Taxonomist.txt') as f:
            text = f.read()
    except:
        raise restlite.Status, '400 Error Reading File'

    return text


# The routes.

routes = [
    (r'GET /resume_text/', 'GET /resume_text/', resume_text),
    (r'GET /keywords/', 'GET /keywords', keywords),
    (r'GET /entities/', 'GET /entities', entities),
]

# Launch the server on port 8000.

if __name__ == '__main__':

    httpd = make_server('', 8000, restlite.router(routes))

    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
Beispiel #13
0
def run_server():
    httpd = make_server('172.27.40.14', 8000, restlite.router(routes))
    httpd.serve_forever()
Beispiel #14
0
    # web files
    (r'GET /(?P<lang>(hi_IN)|(en_US))/(?P<path>.*)$',
     'GET /%(path)s?lang=%(lang)s'),
    (r'GET /(?P<path>((favicon.ico)|(crossdomain.xml)|(embed)|(flvs)|(users)|(download)|(cgi))(/.*)?)',
     'GET /www/%(path)s'),
    (r'GET /www/embed$', 'GET /www/embed/index.swf'),
    (r'GET /www/cgi', cgiscript),
    (r'GET /www', webfile),
    (r'POST /', postscript),
    (r'GET /index.html$', 'GET /'),
    (r'GET /(?P<query>\?.*)?$', indexfile),
    (r'GET /(?P<path>[^\?]+)(?P<query>\?.*)?$', 'GET /%(query)s',
     'TARGET=%(path)s', indexfile)
]
webserver = restlite.router(_routes)

#----------------------------
# FLASH SERVER IMPLEMENTATION
#----------------------------


class Record(rtmp.App):
    def __init__(self):
        rtmp.App.__init__(self)


class Call(rtmp.App):
    def __init__(self):
        rtmp.App.__init__(self)
        self.clientId = 0  # unique client identifier for each client in this call application
Beispiel #15
0
    (r'GET,PUT,POST,DELETE /(?P<type>((xml)|(plain)))/(?P<path>.*)$',
     'GET,PUT,POST,DELETE /%(path)s', 'ACCEPT=text/%(type)s',
     'CONTENT_TYPE=text/%(type)s'),
    (r'GET,PUT,POST,DELETE /(?P<type>(json))/(?P<path>.*)$',
     'GET,PUT,POST,DELETE /%(path)s', 'ACCEPT=application/%(type)s',
     'CONTENT_TYPE=application/%(type)s'),
    # for browser convenience use POST /.../put for PUT and GET /.../delete DELETE
    (r'GET,POST /(?P<path>.*)/delete$', 'DELETE,DELETE /%(path)s'),
    (r'POST /(?P<path>.*)/put$', 'PUT /%(path)s'),

    # user data access at /rest/user
    (r'GET,PUT,POST,DELETE /user', restdata.bind(data, users)),
]

# the top level application to represent URL prefix /rest
wsgiapp = restlite.router(routes)


def _main():
    from wsgiref.simple_server import make_server
    httpd = make_server(
        '', 5080, restlite.router([
            (r'GET,PUT,POST,DELETE /rest', wsgiapp),
        ]))
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass


def _unittest():
Beispiel #16
0
'''
Created on Jan 20, 2012

@author: vramiro
'''

routes = [
 (r'GET /xml/(?P<path>.*)$', 'GET,PUT,POST /%(path)s', 'ACCEPT=text/xml')
 ]

import restlite, wsgiref

httpd = wsgiref.simple_server.make_server('', 8000, restlite.router(routes))
httpd.serve_forever()
Beispiel #17
0
        (r'GET /(?P<path>.*)', do_message),              
    ]

# Find the data in the home directory
if sys.platform == 'win32':
    import _winreg
    home_config = _winreg.ExpandEnvironmentStrings(u'%APPDATA%\\Platane\\')
else:
    home_config = os.path.expanduser("~"+getpass.getuser())+'/.platane/'
root=None
home_root=home_config+"root"
if os.path.exists(home_root):
    root=home_root
    model.root = root

application = restlite.router(routes)    
    
# Starts a standalone instance
if __name__ == '__main__':        
    from wsgiref.simple_server import make_server    
    console_handler = logging.StreamHandler(sys.stdout)
    formatter = logging.Formatter("%(asctime)s %(levelname)s [%(name)s] %(message)s")
    console_handler.setFormatter(formatter)
    logging.getLogger().addHandler(console_handler)
    
    opt_parser=optparse.OptionParser()    
    opt_parser.add_option("-r", "--root", dest="root",
                      help="Root for data", metavar="ROOT")
    opt_parser.add_option("-p", "--port", dest="port",
                      help="Listen port (defaults to 7780)", metavar="PORT")
    opt_parser.add_option("-d", action="store_true", dest="debug", help="Logs debug information on the console")