if created: return self.json_response( {'success': "You are successfully added. We will invite on the beta launch"}) else: return self.json_response( {'success': "We will invite on the beta launch", 'error': "You are already registered."}) else: return self.json_response( {'error': "Wrong Email Address. Please Correct yourself."}) all_urls = [ url('', HomePage, name='default'), url('email', EmailPage, name='email'), url('static/{path:any}', file_handler(root='static/'), name='static') ] options = {} # Template Engine searchpath = [''] engine = Engine( loader=FileLoader(searchpath), extensions=[ CoreExtension(), WidgetExtension(), ]) engine.global_vars.update({ 'h': html_escape
@response_cache(public_cache_profile) @handler_transforms(gzip_transform()) def get(self): # There are two entry points for this handler: # one that respond to / and the other one with # locale in path, e.g. /en. Stick with default # route so menu locate properly reverse url for # current route. self.route_args['route_name'] = 'default' return self.render_response('public/home.html') wraps_handler = lambda p: lambda h: response_cache(p)( response_transforms(gzip_transform(compress_level=9))(h)) extra = { 'translation_name': 'public' } # w = wraps_handler(public_cache_profile, **extra) # home = w(template_handler('public/home.html')) # cached by nginx http400 = template_handler('public/http400.html', status_code=400, **extra) http403 = template_handler('public/http403.html', status_code=403, **extra) http404 = template_handler('public/http404.html', status_code=404, **extra) http500 = template_handler('public/http500.html', status_code=500, **extra) w = wraps_handler(static_cache_profile) static_file = w(file_handler(root='content/static/'))
from wheezy.routing import url from wheezy.web.handlers import file_handler from views import AddHandler from views import ListHandler all_urls = [ url('', ListHandler, name='list'), url('add', AddHandler, name='add'), url('static/{path:any}', file_handler(root='static/'), name='static') ]
status_code=401, subject='Oops! Code 401. Sorry, requires authorization.', message='Your credentials do not allow access to this resource.') http403 = error_response( status_code=403, subject='Oops! Code 403. Access is denied.', message='You do not have permission to view this directory or page \ using the credentials that you supplied.') http404 = error_response( status_code=404, subject='Oops! Code 404. Sorry, we can\'t find that page.', message='Unfortunately the page you are looking for may have been \ removed, had its name changed, under construction or is temporarily \ unavailable. Try checking the web address for typos, please. We apologize \ for the inconvenience.') http500 = error_response( status_code=500, subject='Oops! Code 500. Sorry, we can not process your request.', message='The web server encountered an unexpected condition that \ prevented it from fulfilling the request by the client for access to the \ requested URL.') w = wraps_handler(static_cache_profile) css_file = w(file_handler('content/static/css')) js_file = w(file_handler('content/static/js')) static_file = w(file_handler('content/static'))
return Factory(session_name, self.errors, self.principal) def json_errors(self): assert self.errors r = self.json_response(self.errors) r.status_code = 400 return r def json_response(self, obj): r = HTTPResponse('application/json; charset=UTF-8', 'UTF-8') r.write_bytes(ujson.dumps(obj)) return r compress = handler_transforms(gzip_transform(compress_level=9, min_length=256)) def wraps_handler(p): def wrapper(h): return response_cache(p)( response_transforms(gzip_transform( compress_level=9, min_length=256))(h)) return wrapper static = wraps_handler(public_cache_profile)(file_handler('content/static')) def url_index(path, name=None): return url(path, static, {'path': 'index.html'}, name=name)
from wheezy.web.handlers import file_handler from wheezy.routing import url from caelus import main as caelus_main from prestige import main as prestige_main import os base_dir = 'prestige' theme = 'prestige' env = 'live' if os.environ.get('LIVE') else 'stage' all_urls = { 'caelus':[ url('static/{path:any}', file_handler(root='caelus/static/'), name='static_caelus'), url('(?P<path>.+\.png)', file_handler(root='caelus/'), name='static_png'), url('{path:favicon.ico}', file_handler(root='caelus/'), name='static_favicon'), url('early', caelus_main.EarlyHandler, name="early"), ], 'rkt':[ url('static/{path:any}', file_handler(root='static/'), name='static') ], 'prestige':[ url('static/v/{path:any}', prestige_main.VideoHandler, name='static_movie'), url('static/js/{path:any}', file_handler(root='prestige/static/js/'), name='static_js'), url('static/i/{path:any}', file_handler(root='prestige/static/i/'), name='static_i'), url('static/css/{path:any}', file_handler(root='prestige/static/css/'), name='static_css'), url('static/fonts/{path:any}', file_handler(root='prestige/static/fonts/'), name='static_font'), url('(?P<path>.+\.png)', file_handler(root='prestige/'), name='static_png'), url('early', prestige_main.EarlyHandler, name="early"), url('payment', prestige_main.PaymentHandler, name="payment"), url('thankyou', prestige_main.ReceiptHandler, name="thankyou"), ],
addr_long=dictionary[id]['addr_long'] sendToZigBee(addr_long, addr, data) except Exception as e: print ("Error enviando datos "+ str(e)) response.status_code = 401 return response # URL mapping del Servidor all_urls = [ url('', Home, name="default"), url(r'^nodes', nodes, name='nodes'), url(r'^id', get_id, name='id'), url(r'^data', data, name='data'), url(r'^zigbee', datatoZigBee, name='zigbee'), url('static/{path:any}', file_handler(root='static/'), name='static') ] # Configuracion del servidor HTTP options = {} # Template Engine searchpath = ['templates'] engine = Engine( loader=FileLoader(searchpath), extensions=[ CoreExtension(), WidgetExtension(), ]) engine.global_vars.update({
def __init__(self, line_obj, exc): super(InvalidLineError, self).__init__() self.line = line_obj self.exc = exc def __str__(self): msg = [] for v in self.line.values(): msg.append(unicode(v)) msg.append(unicode(self.exc)) return u' | '.join(msg) url_map = [ url('', MainView, name='index'), url('static/{path:any}', file_handler(root=config.app_path('static/')), name='static'), ] application = WSGIApplication( middleware=[ bootstrap_defaults(url_mapping=url_map), path_routing_middleware_factory ], options=config.options) if __name__ == '__main__': from wsgiref.simple_server import make_server try: LOG.info('Launching on http://localhost:5000/ ...') make_server('', 5000, application).serve_forever()
""" """ from wheezy.http import response_cache from wheezy.http.transforms import gzip_transform from wheezy.http.transforms import response_transforms from wheezy.web.handlers import file_handler from wheezy.web.handlers import template_handler from public.web.profile import public_cache_profile from public.web.profile import static_cache_profile wraps_handler = lambda p: lambda h: response_cache(p)(response_transforms(gzip_transform(compress_level=9))(h)) extra = {"translation_name": "public"} w = wraps_handler(public_cache_profile) home = w(template_handler("public/home.html", **extra)) about = w(template_handler("public/about.html", **extra)) # cached by nginx http400 = template_handler("public/http400.html", status_code=400, **extra) http403 = template_handler("public/http403.html", status_code=403, **extra) http404 = template_handler("public/http404.html", status_code=404, **extra) http500 = template_handler("public/http500.html", status_code=500, **extra) w = wraps_handler(static_cache_profile) static_file = w(file_handler(root="content/static/"))
from caelus import main from prestige import main from slots import lucky try: index = __import__(theme) except ImportError, e: index = hello all_urls = [ url('', getattr(index.main, 'IndexHandler', hello.IndexHandler), name='default'), url('welcome', hello.welcome, name='welcome'), #url('static/{path:any}', file_handler(root='static/'), name='static') url('play', getattr(index.main, 'PlayHandler', hello.IndexHandler), name='play'), url('static/swfobject/{path:any}', file_handler(root='static/swfobject/'), name='static_swfobject'), url('static/swf/{path:any}', file_handler(root='static/swf/'), name='static_swf'), url('s/swz/{path:any}', file_handler(root='static/swf/'), name='compat_swz'), ] all_urls += _config.all_urls[theme] options = { 'XSRF_NAME': '_x', 'render_template': render_template, } amf_endpoints = [ ('play/lucky/remoting', lucky.channel), ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright 2015 blackshirt __author__ = 'simbah' from wheezy.routing import url from wheezy.web.handlers import file_handler from views import IndexHandler from views import AddTrainingHandler, ListTrainingHandler all_urls = [ url('', IndexHandler, name='index'), url('add', AddTrainingHandler, name='add'), url('list', ListTrainingHandler, name='list'), url('static/{path:any}', file_handler(root='static/'), name='static'), url('favicon.ico', file_handler(root='/'), {'path': 'favicon.ico'}) ]
from wheezy.routing import url from wheezy.http import response_cache from wheezy.web.handlers import file_handler from views.views import ListHandler, DetailHandler, DeleteHandler, SoftwareHandler, AboutHandler, ContactHandler, AtomHandler, HttpErrorHandler from datetime import timedelta all_urls = [ url('', ListHandler, name='list'), url('page/{page}', ListHandler, name='page'), url('detail/{id}', DetailHandler, name='detail'), url('reply/{id}', DetailHandler, name='reply'), url('delete/{id}', DeleteHandler, name='delete'), url('delete/reply/{id}', DeleteHandler, name='delete_reply'), url('software', SoftwareHandler, name='software'), url('about', AboutHandler, name='about'), url('contact', ContactHandler, name='contact'), url('atom', AtomHandler, name='atom'), url('img/{path:any}', file_handler(root='contents/static/upload/'), name='img'), url('static/{path:any}', file_handler(root='contents/static/', age=timedelta(hours=1)), name='static'), # http error code url('http400', HttpErrorHandler, name='http400'), url('http401', HttpErrorHandler, name='signin'), url('http403', HttpErrorHandler, name='http403'), url('http404', HttpErrorHandler, name='http404'), url('http500', HttpErrorHandler, name='http500'), ]
from wheezy.web.handlers import BaseHandler from wheezy.web.handlers import file_handler from wheezy.web.handlers import template_handler from public.web.profile import public_cache_profile from public.web.profile import static_cache_profile class WelcomeHandler(BaseHandler): @response_cache(public_cache_profile) @response_transforms(gzip_transform()) def get(self): return self.render_response('public/home.html') wraps_handler = lambda p: lambda h: response_cache(p)(response_transforms( gzip_transform(compress_level=9))(h)) #w = wraps_handler(public_cache_profile) #home = w(template_handler('public/home.html')) # cached by nginx http400 = template_handler('public/http400.html', status_code=400) http403 = template_handler('public/http403.html', status_code=403) http404 = template_handler('public/http404.html', status_code=404) http500 = template_handler('public/http500.html', status_code=500) w = wraps_handler(static_cache_profile) static_file = w(file_handler(root='content/static/', age=timedelta(hours=1))) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
DEBUG = False if socket.gethostbyname(socket.gethostname()) == '192.168.72.100': print('debug mode') DEBUG = True def session(): if DEBUG: return pymysql.connect(db='imgbbs', host='localhost', user='******', passwd='_WioT.A', charset='utf8') else: return pymysql.connect(db='imgbbs', host='localhost', user='******', passwd='_WioT.A', charset='utf8') # secret key secretkey = 'faw_iodjnf+ozx90i2j+lkfals1' static_file = file_handler(root='contents/static/', age=timedelta(hours=1)) template_path = ['contents/templates'] SELECT_LIMIT = 20 # Cache settings cache = MemoryCache() cached = Cached(cache, time=15 * 60) default_cache_profile = CacheProfile('both', duration=60) # options options = { 'render_template': MakoTemplate( input_encoding="utf-8", directories=template_path, filesystem_checks=False, preprocessor=[widget_preprocessor]
""" ``urls`` module. """ from wheezy.routing import url from wheezy.web.handlers import file_handler from views import list all_urls = [url("", list, name="list"), url("static/{path:any}", file_handler(root="static/"), name="static")]
socket.getaddrinfo(parts[0], parts[1]) except (IndexError, socket.error, socket.herror, socket.gaierror, socket.timeout): raise InvalidServerAddress(addr) class InvalidServerAddress(Exception): def __init__(self, addr): super(InvalidServerAddress, self).__init__('Invalid address specified: %s' % addr) url_map = [ url('', MainView, name='index'), url('static/{path:any}', file_handler(root=config.app_path('static/')), name='static'), ] application = WSGIApplication(middleware=[ bootstrap_defaults(url_mapping=url_map), path_routing_middleware_factory ], options=config.options) if __name__ == '__main__': from wsgiref.simple_server import make_server try: LOG.info('Launching on http://localhost:5000/ ...') make_server('', 5000, application).serve_forever() except KeyboardInterrupt: LOG.info('... exiting')