Пример #1
0
#-*- coding:utf-8 -*-
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'


from django.core.handlers.wsgi import WSGIHandler
from bae.core.wsgi import WSGIApplication
application = WSGIApplication(WSGIHandler())
Пример #2
0
    regex = re.compile(PAN_REGEX)
    match = re.search(regex, data)
    if match:
        new_url = match.group(1).replace('amp;', '')
        if new_url.startswith('http'):
            return new_url
    raise web.notfound()


class BaiduPan:
    def GET(self, shareid, uk):
        if (shareid.isdigit() and uk.isdigit()):
            return web.redirect(BaiduPanRealUrl(shareid, uk))
        else:
            return web.notfound()


# 新版度盘分享链接转换代码
class BaiduPan2:
    def GET(self, shareid):
        if (shareid.isalnum()):
            return web.redirect(BaiduPanRealUrlB(shareid))
        else:
            return web.notfound()


app = web.application(urls, globals()).wsgifunc()

from bae.core.wsgi import WSGIApplication
application = WSGIApplication(app)
Пример #3
0
        password = self.get_argument('password')
        user_info = self.db.query(
            "select username, password from pycoder_user")
        for info in user_info:
            if username == info['username'] and password == info['password']:
                self.set_secure_cookie('username', username)
                self.redirect('/')
                return
        self.redirect('/login')


class LogoutHandler(BaseHandler):
    def get(self):
        self.clear_cookie('username')
        self.redirect('/')


if 'SERVER_SOFTWARE' in os.environ:
    from bae.core.wsgi import WSGIApplication
    application = WSGIApplication(Application())
else:
    if __name__ == '__main__':
        #    tornado.options.parse_command_line()
        #创建一个服务器
        http_server = tornado.httpserver.HTTPServer(
            tornado.wsgi.WSGIContainer(Application()))
        #监听端口
        http_server.listen(8080)
        #启动服务
        tornado.ioloop.IOLoop.instance().start()
Пример #4
0
#-*- coding:utf-8 -*-
# import django

# def app(environ, start_response):
#     status = '200 OK'
#     headers = [('Content-type', 'text/html')]
#     start_response(status, headers)
#     # body=["Welcome to Baidu Cloud!\n"]
#     body=['django version: {0} \n'.format(django.get_version())]
#     return body

# application = WSGIApplication(app)

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

from bae.core.wsgi import WSGIApplication
from mysite import wsgi

application = WSGIApplication(wsgi.application)
Пример #5
0
    'ManageFiles',
    '/manage/user',
    'ManageUser',
    '/manage/logout',
    'ManageLogout',
    '/manage/result/(.+)',
    'ManageResult')

#Init Callback interface
app = web.application(urls, globals())
if Setting.runtime == "SAE":
    import sae
    application = sae.create_wsgi_app(app.wsgifunc())
elif Setting.runtime == "BAE":
    from bae.core.wsgi import WSGIApplication
    application = WSGIApplication(app.wsgifunc())
else:
    pass

#Session Regedit
web.config.session_parameters['cookie_name'] = 'Garfitle_session'
web.config.session_parameters['cookie_domain'] = None
web.config.session_parameters['timeout'] = 86400
web.config.session_parameters['ignore_expiry'] = True
web.config.session_parameters['ignore_change_ip'] = True
web.config.session_parameters['secret_key'] = 'GarfieltSoJlRmFs6H2Ll'
web.config.session_parameters['expired_message'] = 'Session expired'

#Init Session
if mc:
    from libs.session import MemcacheStore
Пример #6
0
    from bae.core.wsgi import WSGIApplication
except:
    local = True
    DATABASE_URI = 'mysql://root@localhost/uicer'
else:
    local = False
    DATABASE_URI = 'mysql://%s:%s@%s:%d/YhHPUHZGiGcrmrwNjSNC' % (
        MYSQL_USER, MYSQL_PASS, MYSQL_HOST, int(MYSQL_PORT))

from utils import db
from weixin import weixin
from weibo import weibo

app = Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
app.register_blueprint(weixin, url_prefix='/weixin')
app.register_blueprint(weibo, url_prefix='/weibo')
db.init_app(app)


@app.route("/")
def index():
    return "Hello Shudong!"


if local:
    app.run()
else:
    application = WSGIApplication(app.wsgi_app)
Пример #7
0
#-*- coding:utf-8 -*-
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'webapp.settings'
path = os.path.dirname(os.path.abspath(__file__)) + '/webapp'
if path not in sys.path:
    sys.path.insert(1, path)
from django.core.wsgi import get_wsgi_application
from bae.core.wsgi import WSGIApplication
application = WSGIApplication(get_wsgi_application())
Пример #8
0
                    'message':
                    'OK',
                    'data':
                    'http://%s/%s%s' % (HOST, BUCKET_NAME, filepath)
                })
            else:
                return json.dumps({
                    'code': 1,
                    'message': 'NOT FILE TYPE.',
                    'data': 'null'
                })
    else:
        return ''


def random_string():
    seed = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    sa = []
    for i in range(8):
        sa.append(random.choice(seed))
    salt = ''.join(sa)
    return salt


def allowed_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS


from bae.core.wsgi import WSGIApplication
application = WSGIApplication(app, stdout="log", stderr="log")
Пример #9
0
#-*- coding:utf-8 -*-

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'Need_Server.settings'

path = os.path.dirname(os.path.abspath(__file__)) + '/Need_Server'
if path not in sys.path:
    sys.path.insert(1, path)

from django.core.handlers.wsgi import WSGIHandler
from bae.core.wsgi import WSGIApplication

from django.core.management import execute_from_command_line
# 自动执行collectstatic
# by: 范俊伟 at:2015-06-23
try:
    execute_from_command_line(['manage.py', 'collectstatic', '--noinput'])
except Exception, e:
    print str(e)

application = WSGIApplication(WSGIHandler(), stderr='log')
Пример #10
0
# -*- coding:utf-8 -*-

from manage import app

from bae.core.wsgi import WSGIApplication
application = WSGIApplication(app, stderr='log')
Пример #11
0
#-*- coding:utf-8 -*-

from route import main
try:
    from bae.core.wsgi import WSGIApplication
    application = WSGIApplication(main.app)
except:
    main.app.run(debug=True,
                 use_debugger=True,
                 host='0.0.0.0',
                 port=3000,
                 threaded=False)
Пример #12
0
app = Flask(__name__)
socketio = SocketIO(app)

event_name = 'tieba_dig'


@app.route('/')
def index():
    return render_template('index.html')


@socketio.on(event_name)
def handle_search_para(para):
    print para
    print type(para['rep_num'])
    posts = []
    try:
        query = Query(para)
        print 'done'
        posts = query.find()
    except StandardError, e:
        print e
    emit(event_name, posts)


if __name__ == '__main__':
    socketio.run(app, host='0.0.0.0', port=8888)
else:
    from bae.core.wsgi import WSGIApplication
    application = WSGIApplication(socketio)
Пример #13
0
# -*- coding:utf-8 -*-
__author__ = 'alexday'

from bae.core.wsgi import WSGIApplication

from backend.app import *

backendApp = app

# 支持百度BAE
# 将stderr输出到标准出错的日志,重定向到BAE日志服务器
application = WSGIApplication(backendApp, stderr='log')
Пример #14
0
# -*- coding:utf-8 -*-
__author__ = 'alexday'

from bae.core.wsgi import WSGIApplication

from wxplatform.index import *

wxplatformServer = app

# 支持百度BAE
# 将stderr输出到标准出错的日志,重定向到BAE日志服务器
application = WSGIApplication(wxplatformServer, stderr='log')
Пример #15
0
#-*- coding:utf-8 -*-
from src import web_app


from bae.core.wsgi import WSGIApplication
application = WSGIApplication(web_app)