Пример #1
0
def startServer():
    web.internalerror = web.debugerror
    if USE_SYSTRAY and WIN32:
        print "Quit via systray icon"
    elif not USE_SYSTRAY and WIN32:
        print "Control-C then page reload to quit"
    else: print "Control-C to quit"
    web.run(urls, web.reloader)
Пример #2
0
def webproxy():
    import web, pprint
    urls = ('/(.*)', 'main')
    class main:
        def GET(self, url):
            pprint.pprint(pvs(url, **web.input()))

    web.run(urls, locals())
Пример #3
0
def run():
    """ Run the web UI """

    # UI runs on port 5940
    sys.argv = [sys.argv[0]]
    sys.argv.append("5940")
    print "Starting HarvestMan Web UI at port 5940..."
    web.internalerror = web.debugerror
    web.run(urls, globals(), web.reloader)
Пример #4
0
def main(conf_fname, debug=False):
    sensor_queue = Queue()

    monp = Process(target=mon.run, args=(conf_fname, sensor_queue, debug))
    monp.start()

    web.run(conf_fname, sensor_queue, debug)

    monp.join()
Пример #5
0
def run():
    """ Run the web UI """

    # UI runs on port 5940
    sys.argv = [sys.argv[0]]
    sys.argv.append("5940")
    print "Starting HarvestMan Web UI at port 5940..."
    web.internalerror = web.debugerror
    web.run(urls, globals(), web.reloader)
Пример #6
0
def webproxy():
    import web, pprint
    urls = ('/(.*)', 'main')

    class main:
        def GET(self, url):
            pprint.pprint(pvs(url, **web.input()))

    web.run(urls, locals())
Пример #7
0
Файл: udp.py Проект: lwzm/ep
def loop_father():
    try:
        from web import run
        run()
    except ImportError:
        while True:
            if input("cmd: ") == "q!":
                break
    _term()
Пример #8
0
def main():
    import urbanmediator
    os.chdir(os.path.dirname(urbanmediator.__file__))  #!!!

    if len(sys.argv) == 1:
        try:
            sys.argv[1] = LISTEN_AT
        except:
            sys.argv.insert(1, LISTEN_AT)
    web.run(urls, globals())
Пример #9
0
def main():
  controller = RoombaWebController()
  controller.ResetRoomba()
  """
  controller.StartWebcam()
  controller.StartMicrophone()
  """
  web.webapi.internalerror = web.debugerror
  urls = ('/(.*)', 'controller')
  web.run(urls, locals())
Пример #10
0
def main():
    #if __name__=="__main__":
    #sys.argv.append("5940")
    #Because web.py expects the port to be passed on argv[1] I will replace it here. The original argv[1] is '--genconf'
    sys.argv[1] = '5940'
    print "Starting web.py at port 5940..."
    web.internalerror = web.debugerror
    # Start timer thread to run after 5 seconds
    print 'Waiting for page to load in browser...'
    threading.Timer(5.0, open_page).start()
    web.run(urls, globals(), web.reloader)
Пример #11
0
def main():
    #if __name__=="__main__":
    #sys.argv.append("5940")
    #Because web.py expects the port to be passed on argv[1] I will replace it here. The original argv[1] is '--genconf'
    sys.argv[1]='5940'
    print "Starting web.py at port 5940..."
    web.internalerror = web.debugerror
    # Start timer thread to run after 5 seconds
    print 'Waiting for page to load in browser...'
    threading.Timer(5.0, open_page).start()
    web.run(urls, globals(), web.reloader)
Пример #12
0
def main():

    nargs = len(sys.argv)
    if nargs < 2: sys.exit(0)

    act = sys.argv[1].lower()

    if act == "train": train()
    elif act == "predict": predict(sys.argv[2] if nargs == 3 else "", True)
    elif act == "web": web.run()

    return
Пример #13
0
def start_server():
    web.webapi.internalerror = web.debugerror
    print "start server....."
    if config.listen_port is not 0:
    	if len(sys.argv) > 1:
    		sys.argv[1] = str(config.listen_port)
    	else:
			sys.argv.append(str(config.listen_port))
	
	#config default database conncection that mananged by web
	#web.config.db_parameters = config.db_config['default']
    
    import logging
    logging.basicConfig(level=logging.DEBUG)
    
    web.run(urls, globals(), web.reloader)
Пример #14
0
def run(tagcloud):
    global tagclouder
    tagclouder = tagcloud
    
    middleware = []
    if not PROD:
      middleware.append(web.reloader)
      web.webapi.internalerror = web.debugerror
    

    #web.httpserver.runsimple = web.httpserver.runbasic # did this solve my problems?
    import sys
    if len(sys.argv) > 1:
        sys.argv[1] = IP_PORT
    else:
        sys.argv.append(IP_PORT)

    web.run(urls, globals(), *middleware) #, web.profiler)
Пример #15
0
Файл: ui.py Проект: flerda/ianki
    def startClicked(self):
        ip = str(self.ipEdit.text())
        port = str(self.portEdit.text())
        global sync_cards
        global sync_days
        global sync_paths
        global sync_names
        
        try:
            sync_cards = int(self.scards.text())
        except:
            sync_cards = 1
        try:
            sync_days = int(self.sdays.text())
        except:
            sync_days = 1
        if sync_cards < 1:
            sync_cards = 1
        elif sync_cards > 1000:
            sync_cards = 1000
        if sync_days < 1:
            sync_days = 1
        elif sync_days > 4:
            sync_days = 4

        sync_paths = [d[1] for d in reversed(self.decks) if (d[0].checkState())]
        sync_names = [d[2] for d in reversed(self.decks) if (d[0].checkState())]

        self.config['ianki_ip'] = ip
        self.config['ianki_port'] = port
        self.config['ianki_sync_cards'] = sync_cards
        self.config['ianki_sync_days'] = sync_days
        self.config['ianki_decks'] = sync_paths
        
        #if deck.syncName in self.config['ianki_decks']:

        self.scards.setText(_(str(sync_cards)))
        self.sdays.setText(_(str(sync_days)))
        web.wsgi.connectIP = ip+':'+port

        global urls, glob
        self.logText.append('Starting server at ' + web.wsgi.connectIP +'.')
        self.server = web.run(urls, glob);
        if self.server:
            self.startButton.setEnabled(False)
            self.stopButton.setEnabled(True)
            self.settingsBox.setEnabled(False)
            self.logText.append('Server started.')
        else:
            self.logText.append('Failed to start server.')
Пример #16
0
 def callback():
     run(args)
Пример #17
0
#!/usr/bin/env python
import os
import sys
from web import run

if __name__ == "__main__":
    run()
Пример #18
0
        try :
            f = open(fName(pName))
            print f.read()            
        except Exception, e :
            print "%s" % e

class Save :

    def POST(self,pName):
        try :
            form = web.input()
            pageName = form.pageName
            body = form.body
            f = open(fName(pName),"w")
            f.write(body)
            f.close()
            if form.text :
                f = open("./exports/text/%s.txt"%pageName,"w")
                f.write(form.text)
                f.close()
            print "OK"
            
        except Exception, e :
            print "%s" % e        
        


if __name__ == '__main__':
    web.run(urls, web.reloader)

Пример #19
0
import web
web.run()
Пример #20
0
 def callback():
     run(args, embedded=True)
Пример #21
0
import web
from web.ui import app
import sys

web_port = 5000  #web.get_port()
print >> sys.stderr, 'start service at:', web_port
web.run(app, web_port)
Пример #22
0
async def on_message(m):
    if m.author.id == bot.user:
        return
    if m.guild is not None:
        if m.guild.id not in WHITELISTED_GUILDS:
            logger.warn(f'bad guild: {m.guild.id!r}')
            return

    if m.content.startswith(config.PREFIX):
        cmd = m.content[len(config.PREFIX):].split(" ")[0]
        try:
            await run_cmd(cmd, m)
        except Exception as e:
            if isinstance(e, APIError):
                logger.exception("API error in cmd {cmd}: ")
                await m.channel.send("Enriching Students API error: " + str(e))
            else:
                e = traceback.format_exc()
                logger.exception("Error in cmd {cmd}: {e}")
                await m.channel.send(f"```\n{e}\n```")


if __name__ == '__main__':
    print("Running...")
    logger.info("\n\n-----RESTART-----\n\n")
    logger.info(f"Schedule bot {version} starting...")
    loop = asyncio.get_event_loop()
    loop.create_task(web.run())
    tasks.start(loop)
    bot.run(config.getenv('TOKEN') or input("token: "))
Пример #23
0
def servidor():
    import web
    web.run()
Пример #24
0
            b.tags = b.tags.split()
            if tag in b.tags:
                bookmarks.append(b)
        empty = len(bookmarks) == 0
        web.render("search.html")

    def POST(self, tag):
        i = web.input()
        tags = i.tags.split()
        bookmarks = []
        bs = list(web.select("bookmarks", order="created desc"))
        for b in bs:
            b.tags = b.tags.split()
            if every(lambda t: t in b.tags, tags):
                bookmarks.append(b)
        empty = len(bookmarks) == 0
        web.render("search.html")


def every(f, lst):
    for x in lst:
        if not f(x):
            return False
    return True


web.internalerror = web.debugerror
web.db_parameters = dict(dbn="mysql", user="******", pw="", db="lecker")
if __name__ == "__main__":
    web.run(urls, web.reloader)
Пример #25
0
			import pyvm_extra
			pyvm_extra.thread_status ()
		except:
			pass

	def GET_Index (self):
		web.header ('Content-Type', 'text/html')
		print "<html><body><ul>"
		for i in sorted (PAGES.keys ()):
			print '<li><a href=/%s.html>%s</a>' %(i, i)
			if not PAGES [i].text:
				print "(empty)"
			if PAGES [i].modified ():
				print "(modified<blink>!</blink>)"
		print "</ul></body></html>"

tothewiki=r"""<html><head>
<meta http-equiv=refresh content="2;url=%s">
</head><body>redirecting to %s...
let's hope it works!</body></html>
"""

#
# __main__ -- this is an application
#

port = int (sys.argv [1])
ADDR = "http://"+HOST+":"+str(port)+"/"
file (REDIRECT_DIR+REDIRECT_FILE, 'w').write (tothewiki % (ADDR, ADDR))
web.run (urls)
Пример #26
0
#!/usr/bin/python2.4

import web
import dolphy
import time

web.internalerror = web.debugerror

urls = ('/search', 'Results')


class Results:
    def GET(self):
        web.header('Content-Type', 'text/html')
        query = web.input().get('q')
        start = time.time()
        i = dolphy.Index('data/test.db')
        results = i.search(query, 'simple')
        duration = "%.6f" % (time.time() - start)
        tmp = open('templates/results.html').read()
        web.render(tmp, isString=True)


if __name__ == "__main__":
    web.run(urls)
Пример #27
0
def servidor():
    import web
    web.run()
Пример #28
0
Файл: exp.py Проект: keizo/kulu
    def GET(self):
        print '<html><body>'
        print '<form name="blah" method="post">'
        print '<input type="checkbox" name="boo" value="hoo" />'
        print '<input type="checkbox" name="boo" value="poo" />'
        print '<input type="checkbox" name="noo" checked="false" />'
        print '<input type="checkbox" name="noo" checked="checked" />'
        print myform.render()
        print '<input type="submit" />'
        print '</form></body></html>'
    def POST(self):
        print web.input(boo=[], noo=[])
#
## MIDDLEWARE FACTORIES
#
def session_mw(app):
    sessionStore = DatabaseSessionStore(timeout=5)
    return SessionMiddleware(sessionStore, app) 


#web.webapi.internalerror = web.debugerror
if __name__ == "__main__": 
    web.config.db_parameters = dict(dbn='mysql', user=db_params.user, pw=db_params.password, db=db_params.database)
    
    #production:
    #web.run(urls, globals(), *[session_mw])
    
    #development laptop:
    web.internalerror = web.debugerror
    web.run(urls, globals(), *[web.reloader])
Пример #29
0
        song = q.get_next_song(only_downloaded=True)
        # If there is no song
        if song is None:
            if st.open:
                logger.warn("There are no songs on the queue!")
                st.stop()
            # Wait 0.2 seconds and try again
            time.sleep(0.2)
            continue

        if not st.open:
            st.start()

        # Stream the song
        st.send_file(song)

        # Remove the song from the queue
        q.remove_song(song["id"])


if __name__ == "__main__":
    q = songqueue.SongQueue()

    download_thread = threading.Thread(target=download_task, args=(q, ))
    download_thread.start()

    stream_thread = threading.Thread(target=stream_task, args=(q, ))
    stream_thread.start()

    web.run(q)
Пример #30
0
import web
urls = ('/(.*)', 'hello')
class hello:        
    def GET(self, name):
        i = web.input(times=1)
        if not name: name = 'world'
        for c in xrange(int(i.times)): print 'Hello,', name+'!'
if __name__ == "__main__": web.run(urls, globals())
Пример #31
0
from harvestman.lib import gui

index = gui.HarvestManConfigGenerator
urls = ('/', 'index')

def open_page():
    print 'Opening page...'
    webbrowser.open("http://localhost:5940")

if __name__=="__main__":
    sys.argv.append("5940")
    print "Starting web.py at port 5940..."
    web.internalerror = web.debugerror
    # Start timer thread to run after 5 seconds
    print 'Waiting for page to load in browser...'
    threading.Timer(5.0, open_page).start()
    web.run(urls, globals(), web.reloader)

#Allows to be imported and run
def main():
    #if __name__=="__main__":
    #sys.argv.append("5940")
    #Because web.py expects the port to be passed on argv[1] I will replace it here. The original argv[1] is '--genconf'
    sys.argv[1]='5940'
    print "Starting web.py at port 5940..."
    web.internalerror = web.debugerror
    # Start timer thread to run after 5 seconds
    print 'Waiting for page to load in browser...'
    threading.Timer(5.0, open_page).start()
    web.application(urls, globals()).run()
Пример #32
0
def runserver():
    web.webapi.internalerror = web.debugerror
    web.run(urls, globals(), web.reloader)
Пример #33
0
def main():
    storage.set_up(config.redis_config.get("host"), config.redis_config.get("port"), config.redis_config.get("db"))
    mqtt.set_up(config.mqtt_broker.get("host"), config.mqtt_broker.get("port"), register_modules)
    websocket.start_server(config)
    web.run()
Пример #34
0
def main():
    web.run()
Пример #35
0
print 'setting up start up middleware'
#
## MIDDLEWARE 
#
class start_mw:
    def __init__(self,app):
        web.load()
        self.load()
        self.app = app
    def __call__(self, e, o): 
        return self.app(e, o)
        
    def load(self):
        glbl.load()

#
## RUN
#
web.webapi.internalerror = web.debugerror
if __name__ == "__main__": 
    print 'setting up db'
    web.config.db_parameters = dict(dbn='mysql', user=db_params.user, pw=db_params.password, db=db_params.database)
    print 'setting up loadhooks'
    web._loadhooks['aliased_url'] = aliased_url 
    
    #mw = [start_mw, web.profiler]
    mw = [start_mw]
    print 'starting server'
    web.run(urls, globals(), *mw)
    
Пример #36
0
            #let's start matching
            found_in_index = False
            for iname in config.re_url_order:
              #if debug: req.write("<br/>testing against index "+iname+", with re"+config.re_url[iname])
              if re.match(config.re_url[iname], f):
                if not cached_values.has_key(iname):
                  cached_values[iname] = indexhelper.get_all_values(iname)
                all_index_values = cached_values[iname]
                #we need to test if there are values for this key/index first
                web.debug("[URL_PARSE]"+f+" compatible with index "+iname+", checking keys"+str(all_index_values))
                if f in all_index_values:
                  index.append(iname)
                  key.append(f)
                  #if debug: req.write("<br/>found index "+iname+" with value "+f)
                  found_in_index = True
                  break
            if not found_in_index:
              index.append("tag")
              key.append(f)
          if no_value_for_index: break

      browseui.print_selection(index, key, file_id, response_format, sizeX)
    else:
      browseui.print_selection()

#if __name__ == "__main__": web.run(urls, web.reloader)
if __name__ == "__main__": web.run(urls)

#web.py 2.0 
#if __name__ == "__main__": web.run(urls, globals())
Пример #37
0
#!/usr/bin/env python3

# import our custom web package
import web

if __name__ == '__main__':
    web.run(debug=True)
Пример #38
0
                out += '<input type="text" size="1" name="%s" />' % (
                    sudo.squares[n])
                n += 1
            out += '<br />'

        return out

    def work(self, **kw):
        values = dict((s, sudo.digits) for s in sudo.squares)
        for k, v in kw.iteritems():
            if v:
                sudo.assign(values, k, v)

        for k, v in values.iteritems():
            if len(v) == 1:
                setattr(self, k, v)

        return values


class length(pwt):
    def form(self):
        return '<p id="output">&nbsp;</p><input type="range" name="n" value="0" />'

    def work(self):
        self.output = ('a' * web.intget(self.n, 0) or '&nbsp;')


if __name__ == "__main__":
    web.run(urls, globals(), web.reloader)
Пример #39
0
        # in old Python versions:
        # if seen.has_key(marker)
        # but in new ones:
        if marker in seen: continue
        seen[marker] = 1
        result.append(item)
    return result


    
#########################################################################

render = web.template.render('templates/', cache='DEV' not in os.environ)
template.Template.globals['len'] = len
template.Template.globals['version'] = '7'
flof = FlofFacade()

mapService = MapService('osm-iphone-big', '../osm/mapnik/osm-shirley.xml', \
           'static/images/watermark.png', '/tmp/tilecache')

mapServiceMini = MapService('osm-iphone-thumb',  \
           '../osm/mapnik/osm-shirley.xml', \
           'static/images/watermarkmini.png', '/tmp/tilecache')

if __name__ == "__main__":
    if 'DEV' in os.environ:
        middleware = [web.reloader]
    else:
        middleware = []
    web.run(urls, globals(), *middleware)
Пример #40
0
                out.append(c.get_response().data)
            return "".join(out)
        else:
            return None


class index:

    def GET(self):
        print render.index()


class related:

    def GET(self, oclcnum):
        numcite = CitationRequest(wskey=WSKEY, \
                    rec_num=oclcnum).get_response().data
        print render.related(oclcnum=oclcnum, numcite=numcite,
                                response=get_related(oclcnum))

    def POST(self):
        oclcnum = web.input().oclcnum
        numcite = CitationRequest(wskey=WSKEY, \
                    rec_num=oclcnum).get_response().data
        print render.related(oclcnum=oclcnum, numcite=numcite,
                                response=get_related(oclcnum))

web.webapi.internalerror = web.debugerror
if __name__ == '__main__':
    web.run(urls, globals())
Пример #41
0
# Once initialized they are state-less so they are safe to use in several
# threads while serving concurrent requests.
myform = AddUserForm('form')

# The web.py app
class formcontroller:
    def GET(self):
        # It is very important to set the Content-Type header properly because
        # if it is not text/html (or application/xhtml) TW's middleware will
        # not attempt to inject resources.
        web.header('Content-Type', 'text/html')
        form_output = myform.display(Person())
        print template % locals()

    def POST(self):
        try:
            form_data = myform.validate(web.input())
        except Invalid:
            # Re-display errors and previous input values
            web.header('Content-Type', 'text/html')
            form_output = myform.display()
            print template % locals()
        else:
            web.header('Content-Type', 'text/plain')
            print pformat(form_data)
            

if __name__ == "__main__":
    web.webapi.internalerror = web.debugerror
    web.run(('/', 'formcontroller'), globals(), tw.api.make_middleware)
Пример #42
0
import constants
import web

if __name__ == "__main__":  # ceci permet d'executer ce code seulement si invoquer directement avec `python main.py`
    print("The web server will be served at http://localhost:{}/".format(constants.WEB_PORT))
    web.run(handler_class=web.CalendarWeb, port=constants.WEB_PORT)
Пример #43
0
import web
import view, config
from view import render

urls = ('/', 'Index')


class Index:
    def GET(self):
        print render.base(view.listing())


if __name__ == '__main__':
    web.run(urls, globals(), *config.middleware)
Пример #44
0
  '/', 'Index',
  '/(\w+).svg', 'SVGMaker',
  '/(graph.(css))', 'Files',
  '/(gradient.(png))', 'Files',
  '/(timeline.(html))', 'Files',
  '/events.xml', 'Events'
)

multiuser = False

if __name__ == '__main__':
    from os.path import dirname, abspath
    sys.path.append(dirname(dirname(abspath(__file__))))
    def createSession(x):
        return session.SessionMiddleware(x, key='todo')
    web.run(urls, createSession, web.reloader)

from todo import svg, parser, html, timeline

typeToMime = {'css':'text/css', 'png':'image/png', 'html':'text/html'}

class Files:
    def GET(self, name, type):
        web.header('Content-Type', typeToMime[type])
        print open(name).read()

form = '''<form action="." method="POST" enctype="multipart/form-data">
<h3>todo.txt</h3>
<input type="file" name="open" />
<h3>done.txt</h3>
<input type="file" name="done" />
Пример #45
0
import web 

if __name__ == "__main__":
    web.run()
Пример #46
0
            events = [e for e in db.get_events(limit='100', order='time_taken desc', where ="taken_from= '%s'" % (source))]
            render_cached_feed(events, feed_type)

class feed:
    def GET(self, format_type='atom'):
        events = [e for e in db.get_events(limit='100', order='time_taken desc', where='duplicateof is null')]
        web.debug(type(events[0].name))
        render_cached_feed(events, format_type)

def render_cached_feed(events, format_type='atom'):
    last_modif_time = events[0].time_taken
    web.debug(last_modif_time)
    #http conditional get
    if not config.http_conditional_get or web.modified(last_modif_time):
        web.lastmodified(last_modif_time)
        web.header("Content-Type", "application/atom+xml")
        web.debug(len(events))
        print render.events_atom_feed(config, last_modif_time, events)


def runfcgi_apache(func):
    web.wsgi.runfcgi(func, None)

if __name__ == "__main__": 
    import os
    if "LOCAL" not in os.environ:
        #web.wsgi.runwsgi = runfcgi_apache
        pass
    web.run(urls, globals(), *config.middleware)
    #application = web.wsgifunc(web.webpyfunc(urls, globals()))
Пример #47
0
def basic():
    web.run(urls, globals())
Пример #48
0
    ct = " - ".join(curr())
    print render.base(track = ct)
    print render.bottom

class prev:
  def GET(self):
    ct = " - ".join(curr())
    print render.base(track = ct)
    print "<b>Previous track requested</b>"
    print render.bottom
    interface.previous_track()

class next:
  def GET(self):
    ct = " - ".join(curr())
    print render.base(track = ct)
    print "<b>Next track requested</b>"
    print render.bottom
    interface.next_track()

class playpause:
  def GET(self):
    ct = " - ".join(curr())
    print render.base(track = ct)
    print "<b>Toggled play/pause</b>"
    print render.bottom
    interface.playpause()

web.webapi.internalerror = web.debugerror
if __name__ == '__main__': web.run(urls, globals())
Пример #49
0
def main():
    opts, args = _get_opt()
    run(debug=opts.debug,
        port=opts.port,
        handlers=my_handlers,
        callback=_show_info)
Пример #50
0
            entry = Entry(owner=user, url=form['url'].value)
            entry.put()
        else:
            raise web.Error(400, 'no image/url included')

@check_user
def handle_request(path):
    if path == '/':
        print template.render('templates/frontpage.tmpl', {})
    elif path == '/cycle':
        print template.render('templates/image.tmpl',
                              { 'json': current_json(),
                                'query': os.environ.get('QUERY_STRING', ''),
                                'cycle': 1 })
    elif path == '/new':
        return new(path)
    elif path.startswith('/image/'):
        id = int(path[len('/image/'):])
        entry = Entry.get_by_id(id)
        if not entry:
            raise web.Error(404)
        print entry.image
        return {}
    elif path == '/json':
        print current_json()
        return {'Content-Type': 'application/json'}
    else:
        raise web.Error(404)

web.run(handle_request)
Пример #51
0
        marker = idfun(item)
        # in old Python versions:
        # if seen.has_key(marker)
        # but in new ones:
        if marker in seen: continue
        seen[marker] = 1
        result.append(item)
    return result


#########################################################################

render = web.template.render('templates/', cache='DEV' not in os.environ)
template.Template.globals['len'] = len
template.Template.globals['version'] = '7'
flof = FlofFacade()

mapService = MapService('osm-iphone-big', '../osm/mapnik/osm-shirley.xml', \
           'static/images/watermark.png', '/tmp/tilecache')

mapServiceMini = MapService('osm-iphone-thumb',  \
           '../osm/mapnik/osm-shirley.xml', \
           'static/images/watermarkmini.png', '/tmp/tilecache')

if __name__ == "__main__":
    if 'DEV' in os.environ:
        middleware = [web.reloader]
    else:
        middleware = []
    web.run(urls, globals(), *middleware)
Пример #52
0
 def callback():
     run(False)
Пример #53
0
import web

urls = (
    '/openmovilforum/mms', 'mms.MMSSenderSrv.view',
    '/openmovilforum/sms', 'sms.SMSSenderSrv.view',
    '/openmovilforum/agenda', 'agenda.AgendaSrv.view',
    '/greeting', 'greeting.GreetingSrv.view',
)

web.webapi.internalerror = web.debugerror
if __name__ == "__main__": web.run(urls, globals(), web.reloader)
Пример #54
0
import time
from thread import *
from collections import deque
import web
import spi
import mux

PORT = 8080
DQ_MAX_LENGTH = 10000

def signal_handler(signal, frame):
    """
    For when we hit CTRL+C!
    """
    print(('End of run: {!s}'.format(time.time())))
    sys.exit(0)

def application_setup():
    signal.signal(signal.SIGINT, signal_handler) #handler for keyboard interrupt

if __name__ == "__main__":
    print('Setting up')
    application_setup()
    spi.setup()
    print(('Start of run: {!s}'.format(time.time())))
    print('Channel 14,Channel 15,Channel 16')

    if len(sys.argv) > 1:
        PORT = sys.argv[1]
    web.run(PORT)
Пример #55
0
        if not this_form.valid:
            print '<p class="error">Try again:</p>'
        print this_form.render()
        print '<input type="submit"></form>'
        if this_form['start'].value:
            file = this_form['file'].value
            (offset, length) = start_and_len(file, int(this_form['start'].value), int(this_form['count'].value))
            print "%.1fKB" % (float(length) / 1024.0)
            url = "http://wiki-beta.us.archive.org:9090/%s:%d:%d" % (file, offset, length)
            print '<a href="%s">download</a>' % url

class get:
    def GET(self, file, offset, length):
        offset = int(offset)
        length = int(length)
        web.header("Content-Type","application/octet-stream")
        r0, r1 = offset, offset+length-1
        url = "http://archive.org/download/bpl_marc/" + file
        ureq = urllib2.Request(url, None, {'Range':'bytes=%d-%d'% (r0, r1)},)
        f = urllib2.urlopen(ureq)
        while 1:
            buf = f.read(1024)
            if not buf:
                break
            web.output(buf)
        f.close()

web.webapi.internalerror = web.debugerror

if __name__ == "__main__": web.run(urls, globals(), web.reloader)
Пример #56
0
        玩家7:<input type="text" name="user7"/><br/>
        玩家8:<input type="text" name="user8"/><br/>
        玩家9:<input type="text" name="user9"/><br/>
        <input type="submit" value="开战"/>
        </form>
        
        </body>
        </html>

        """

class btfight:
    def POST(self):
        print '''
        <html>
        <head><title>PKGame</title>
        <META CONTENT="text/html; charset=utf-8" HTTP-EQUIV="Content-Type" />
        </head>
        <body>
        <pre>'''
        i = web.input()
        game = Interface()
        game.setPlayers(i.values())
        game.Play()
        print '</pre></body></html>'
        
        
web.internalerror = web.debugerror

if __name__ == '__main__': web.run(urls, web.reloader)
Пример #57
0
        height = int(height)

        series_set = get_series(username, 12, 25)

        # Create the output
        output = FileOutput(padding=0, style=long_style)
        scale = AutoWeekDateScale(series_set)

        # OK, render that.
        wg = WaveGraph(series_set,
                       scale,
                       long_style,
                       not bool(labels),
                       textfix=True)
        output.add_item(wg, x=0, y=0, width=width, height=height)
        print output.stream('pdf').read()


class Colours:
    def GET(self, username):

        series_set = get_series(username)

        for series in series_set:
            print "%s,%s" % (series.title, series.color)


#web.webapi.internalerror = web.debugerror
if __name__ == "__main__":
    web.run(urls, globals())
Пример #58
0
def web_starter():
    print("################################################################")
    print("Start web")
    print("################################################################")
    web.run(obs)