Пример #1
0

@route('/auth/login', method=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.POST.get("username", '')
        password = request.POST.get("password", '')
        if password == config.admin_pwd and username == config.admin_user:
            session = get_current_session()
            session['username'] = username
            return {'code': 0, 'msg': 'OK'}
        else:
            return {'code': -1, 'msg': '用户名或密码错误'}
    else:
        return template('auth/login.html', config=config, media_prefix=media_prefix)


@route('/auth/logout')
def logout():
    session = get_current_session()
    del session['username']
    return redirect(request.params.get('next') or '/')


if __name__ == "__main__":
    from mole.mole import default_app
    from mole.sessions import SessionMiddleware

    app = SessionMiddleware(app=default_app(), cookie_key="457rxK3w54tkKiqkfqwfoiQS@kaJSFOo8h", no_datastore=True)
    run(app=app, host=config.host, port=config.port, reloader=config.debug)
Пример #2
0
    if new:
        change_ttl(key,int(new),cl)
    return '<script type=text/javascript> alert("ok");window.location.href=document.referrer</script>'

@route('/rename')
def rename():
    from data_change import rename_key
    cl,cur_server_index,cur_db_index = get_cl()
    key = request.GET.get('key', None)
    new = request.GET.get('new', None)
    rename_key(key,new,cl)
    return '<script type=text/javascript> alert("ok");parent.location.reload();</script>'

@route('/export')
def export():
    return 'Still in developme. You can see it in next version.'

@route('/import')
def iimport():
    return 'Still in developme. You can see it in next version.'

@route('/save')
def save():
    cl,cur_server_index,cur_db_index = get_cl()
    cl.bgsave()
    return '<script type=text/javascript> alert("ok");window.location.href=document.referrer</script>'


if __name__  == "__main__":
    run(host=config.host, port=config.port, reloader=config.debug)
Пример #3
0

@route('/auth/login', method=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.POST.get("username", '')
        password = request.POST.get("password", '')
        if password == config.admin_pwd and username == config.admin_user:
            session = get_current_session()
            session['username'] = username
            return {'code': 0, 'msg': 'OK'}
        else:
            return {'code': -1, 'msg': '用户名或密码错误'}
    else:
        return template('auth/login.html', config=config, media_prefix=media_prefix)


@route('/auth/logout')
def logout():
    session = get_current_session()
    del session['username']
    return redirect(request.params.get('next') or '/')


if __name__ == "__main__":
    from mole.mole import default_app
    from mole.sessions import SessionMiddleware

    app = SessionMiddleware(app=default_app(), cookie_key="457rxK3w54tkKiqkfqwfoiQS@kaJSFOo8h", no_datastore=True)
    run(app=app, host=config.host, port=config.port, reloader=config.debug)
Пример #4
0
                        cookie_key="457rxK3w54tkKiqkfqwfoiQS@kaJSFOo8h",
                        no_datastore=True)

if __name__ == "__main__":
    parser = OptionParser(usage="usage: python %prog [options] filename",
                          version="YouMd %s" % version)
    parser.add_option("-p",
                      "--port",
                      action="store",
                      type="int",
                      dest="port",
                      default=8081,
                      help="Listen Port. default=8081")
    parser.add_option("-H",
                      "--host",
                      action="store",
                      type="string",
                      dest="host",
                      default='0.0.0.0',
                      help="Server host address. default=0.0.0.0")
    parser.add_option("-s",
                      "--server",
                      action="store",
                      type="string",
                      dest="server",
                      default='wsgiref',
                      help="Type of server. default=wsgiref")
    (options, args) = parser.parse_args()

    run(app=app, host=options.host, port=options.port, server=options.server)
Пример #5
0
# -*- coding: utf-8 -*-
##################### 系统环境设置 #######################
def set_lib_path():
    import sys
    import os
    sys.path.append('./lib')
set_lib_path()

#安装的apps、mosys系统模块(有先后顺序)
import site_apps
import mocrud
import mosys
mosys.setup(site_apps)


#加入SessionMiddleware 中间件
from mole.sessions import SessionMiddleware
app = SessionMiddleware(app=site_apps.app, cookie_key=site_apps.COOKIE_KEY,no_datastore=True)

#运行服务器
from mole import run
if __name__  == "__main__":
    run(app=app,host='0.0.0.0', port=8081)
Пример #6
0
# -*- coding: utf-8 -*-
from mole import route, run, static_file, error,get, post, put, delete, Mole
from mole.template import template
from mole import request
from mole import response
    
@route('/visit')
def visit():
    if request.get_cookie("visited"):
        return "Welcome back! Nice to see you again"
    else:
        response.set_cookie("visited", "yes")
        return "Hello there! Nice to meet you"
    
@route('/')
def index():
    return 'Hello Mole!'

if __name__  == "__main__":
    run(host='localhost', port=8080, reloader=True)
Пример #7
0
# -*- coding: utf-8 -*-
##################### 系统环境设置 #######################
def set_lib_path():
    import sys
    import os
    sys.path.append('./lib')
set_lib_path()

#安装的apps、mosys系统模块(有先后顺序)
import apps
import mocrud
import mosys


#加入SessionMiddleware 中间件
from mole.sessions import SessionMiddleware
app = SessionMiddleware(app=apps.app, cookie_key=apps.COOKIE_KEY,no_datastore=True)


#import os
#os.environ['MOLESYS_SETTINGS'] = apps
#运行服务器
from mole import run
if __name__  == "__main__":
    run(app=app,host='localhost', port=8081)
Пример #8
0
@route('/rename')
def rename():
    from data_change import rename_key
    cl, cur_server_index, cur_db_index = get_cl()
    key = request.GET.get('key', None)
    new = request.GET.get('new', None)
    rename_key(key, new, cl)
    return '<script type=text/javascript> alert("ok");parent.location.reload();</script>'


@route('/export')
def export():
    return 'Still in developme. You can see it in next version.'


@route('/import')
def iimport():
    return 'Still in developme. You can see it in next version.'


@route('/save')
def save():
    cl, cur_server_index, cur_db_index = get_cl()
    cl.bgsave()
    return '<script type=text/javascript> alert("ok");window.location.href=document.referrer</script>'


if __name__ == "__main__":
    run(host=config.host, port=config.port, reloader=config.debug)
Пример #9
0
def _web_run(port = 8000):
    app = SessionMiddleware(app=default_app(), cookie_key="457rxK3w54tkKiqkfqwfoiQS@kaJSFOo8h",no_datastore=True)
    run(app=app, host='0.0.0.0', port = port, reloader = True);
Пример #10
0
# -*- coding: utf-8 -*-
##################### 系统环境设置 #######################
def set_lib_path():
    import sys
    import os

    sys.path.append("./libs")


set_lib_path()

import mocrud
import crud_example


from mole.mole import default_app

# 加入SessionMiddleware 中间件
from mole.sessions import SessionMiddleware

app = SessionMiddleware(app=default_app(), cookie_key="457rxK8ytkKiqkfqwfoiQS@kaJSFOo8h", no_datastore=True)


# 运行服务
from mole import run

if __name__ == "__main__":
    run(app=app, host="0.0.0.0", port=8081)
Пример #11
0
    sys.path.append('./lib')
    sys.path.append('../../../python-support')
    #os.environ["PYTHONPATH"]='../'


set_lib_path()

#安装的mosys、apps系统模块
import apps
import mosys
from mole.const import TEMPLATE_PATH
TEMPLATE_PATH.append('./apps/templates/')
TEMPLATE_PATH.append('./lib/mosys/templates/')

#安装的PyRedisAdmin
import PyRedisAdmin.routes
import serverM.routes
TEMPLATE_PATH.append('./lib/PyRedisAdmin/templates/')

#加入SessionMiddleware 中间件
COOKIE_KEY = '457rxK8ytkKiqkfqwfoiQS@kaJSFOo8h'
from mole.mole import default_app
from mole.sessions import SessionMiddleware
app = default_app()
app = SessionMiddleware(app=app, cookie_key=COOKIE_KEY, no_datastore=True)

#运行服务器
from mole import run
if __name__ == "__main__":
    run(app=app, host='0.0.0.0', port=8123, reloader=True)
Пример #12
0
@route('/rename')
def rename():
    from data_change import rename_key
    cl, cur_server_index, cur_db_index = get_cl()
    key = request.GET.get('key', None)
    new = request.GET.get('new', None)
    rename_key(key, new, cl)
    return '<script type=text/javascript> alert("ok");parent.location.reload();</script>'


@route('/export')
def export():
    return 'Still in developme. You can see it in next version.'


@route('/import')
def iimport():
    return 'Still in developme. You can see it in next version.'


@route('/save')
def save():
    cl, cur_server_index, cur_db_index = get_cl()
    cl.bgsave()
    return '<script type=text/javascript> alert("ok");window.location.href=document.referrer</script>'


if __name__ == "__main__":
    run(host='0.0.0.0', port=8085, reloader=True)
Пример #13
0
# coding=utf-8
from mole import run

import routes

if __name__ == "__main__":
    run(host='0.0.0.0', port=8081)
Пример #14
0
# coding=utf-8
from mole import run

import routes

if __name__  == "__main__":
    run(host='0.0.0.0', port=8081)
Пример #15
0
    if new:
        change_ttl(key,int(new),cl)
    return '<script type=text/javascript> alert("ok");window.location.href=document.referrer</script>'

@route('/rename')
def rename():
    from data_change import rename_key
    cl,cur_server_index,cur_db_index = get_cl()
    key = request.GET.get('key', None)
    new = request.GET.get('new', None)
    rename_key(key,new,cl)
    return '<script type=text/javascript> alert("ok");parent.location.reload();</script>'

@route('/export')
def export():
    return 'Still in developme. You can see it in next version.'

@route('/import')
def iimport():
    return 'Still in developme. You can see it in next version.'

@route('/save')
def save():
    cl,cur_server_index,cur_db_index = get_cl()
    cl.bgsave()
    return '<script type=text/javascript> alert("ok");window.location.href=document.referrer</script>'


if __name__  == "__main__":
    run(host='0.0.0.0', port=8085, reloader=True)
Пример #16
0
# -*- coding: utf-8 -*-
from mole import route, run, static_file, error, get, post, put, delete, Mole
from mole.template import template
from mole import request
from mole import response


@route('/visit')
def visit():
    if request.get_cookie("visited"):
        return "Welcome back! Nice to see you again"
    else:
        response.set_cookie("visited", "yes")
        return "Hello there! Nice to meet you"


@route('/')
def index():
    return 'Hello Mole!'


if __name__ == "__main__":
    run(host='localhost', port=8080, reloader=True)
Пример #17
0
# -*- coding: utf-8 -*-

import mocrud
#import crud_example
import db

from mole.mole import default_app
#加入SessionMiddleware 中间件
from mole.sessions import SessionMiddleware

app = SessionMiddleware(app=default_app(),
                        cookie_key="457rxK8ytkKiqkfqwfoiQS@kaJSFOo8h",
                        no_datastore=True)

#运行服务
from mole import run
if __name__ == "__main__":
    run(app=app, host='0.0.0.0', port=8081)
Пример #18
0
version = '1.1.0'

import routes

app = SessionMiddleware(app=default_app(), cookie_key="457rxK3w54tkKiqkfqwfoiQS@kaJSFOo8h",no_datastore=True)

if __name__  == "__main__":
    parser = OptionParser(usage="usage: python %prog [options] filename",
                          version="YouMd %s" % version)
    parser.add_option("-p", "--port",
                      action="store",
                      type="int",
                      dest="port",
                      default=8081,
                      help="Listen Port. default=8081")
    parser.add_option("-H", "--host",
                      action="store",
                      type="string",
                      dest="host",
                      default='0.0.0.0',
                      help="Server host address. default=0.0.0.0")
    parser.add_option("-s", "--server",
                      action="store",
                      type="string",
                      dest="server",
                      default='wsgiref',
                      help="Type of server. default=wsgiref")
    (options, args) = parser.parse_args()
    
    run(app=app, host=options.host, port=options.port, server=options.server)