Пример #1
0
import os
from typing import Dict
from flask import Flask, request, render_template
from flask_socketio import SocketIO
from server.sanitizer import sanitize
from server.logger import create_logger
import server.ticker as ticker
from server.domain import ClientEvent
from server.utils import from_dict

log = create_logger(__name__)
log.game_event('created logger')

app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ.get('GAME_SECRET', 'notarealsecret')
HOST = os.environ.get('GAME_HOST', '127.0.0.1')
PORT = os.environ.get('GAME_PORT', 5000)

socketio = SocketIO(app)
client_names: Dict[str, str] = {}


@app.route('/')
def homepage():
    """Render the index.html file that contains the frontend application."""
    return render_template('index.html')


@socketio.on('connect')
def handle_connect():
    # Authentication can go here
Пример #2
0
import datetime
from flask import Flask, render_template
from flask import Markup
from flask_restplus import Api

from conn.mysqldb import MySQLdb
from scheduler.scheduler import Scheduler
from server.decorators import DictModel
from server.logger import create_logger
from server.super_config import SuperConf
from scheduler.scheduler import SchedulerConfig

config = SuperConf(path='superconf.json')

# 日志对象
log = create_logger(config, 'server')

# Flask 对象
app = Flask(__name__)
app.jinja_env.filters['json'] = lambda v: Markup(json.dumps(v))
app.secret_key = '\x1a\x8dfb#\xb9\xc8\xc3\x05\x86|\xda\x96\xff\xceo3\xf0\xa3\xb8\x8beoW'

# 调度对象
app.config.from_object(SchedulerConfig())
scheduler = Scheduler()
scheduler.init_app(app)
scheduler.start()

# Flask API 对象
api = Api(app,
          version='1.0.0',
Пример #3
0
import datetime
from flask import Flask, render_template
from flask import Markup
from flask_restplus import Api

from conn.mysqldb import MySQLdb
from scheduler.scheduler import Scheduler
from server.decorators import DictModel
from server.logger import create_logger
from server.super_config import SuperConf
from scheduler.scheduler import SchedulerConfig

config = SuperConf(path='superconf.json')

# 日志对象
log = create_logger(config.log, 'util')

# Flask API 对象
app = Flask(__name__)
app.jinja_env.filters['json'] = lambda v: Markup(json.dumps(v))
app.secret_key = '\x1a\x8dfb#\xb9\xc8\xc3\x05\x86|\xda\x96\xff\xceo3\xf0\xa3\xb8\x8beoW'

# 调度对象
app.config.from_object(SchedulerConfig())
scheduler = Scheduler()
scheduler.init_app(app)
scheduler.start()

# 接口API
api = Api(app,
          version='1.0.0',
Пример #4
0
"""
配置文件载入所有配置
"""
from conn.mysqldb import MySQLdb
from flask import Flask
import json
from flask import Markup

from server.super_config import SuperConf
from server.logger import create_logger
from server.decorators import DictModel
from scheduler.scheduler import SchedulerConfig, Scheduler

# 配置文件
config = SuperConf(path='superconf.json')

# Flask API 对象
app = Flask(__name__)
app.jinja_env.filters['json'] = lambda v: Markup(json.dumps(v))
app.secret_key = '\x1a\x8dfb#\xb9\xc8\xc3\x05\x86|\xda\x96\xff\xceo3\xf0\xa3\xb8\x8beoW'

# 调度对象
app.config.from_object(SchedulerConfig())
scheduler = Scheduler()

# 日志对象
log = create_logger(config, 'exec')

# 数据库连接
db = DictModel({'etl_db': MySQLdb(dict(config.mysql.etl))})