Exemplo n.º 1
0
def run_server():
    '''
    Start the Flask server
    '''
    # SocketIO objects are defined in config.py
    socketio.run(server,
                 host="127.0.0.1",
                 port=23948,
                 debug=True,
                 use_reloader=False)
Exemplo n.º 2
0
    room = data['room']
    join_room(room)
    print("user {} is now in rooms: {}".format(request.sid,
                                               rooms(request.sid)))


# This is just a test endpoint for sending messages via the websocket
from flask import jsonify


@app.route('/message/<string:room>/<string:message>')
def ahhh(room, message):
    socketio.emit('update', {'message': message}, room=room)
    return jsonify({'message': message})


# Required since running Flask in debug modes kicks it off twice
# this code will be run any time we have the first caller to our webserver
@app.before_first_request
def before_first_request():
    dataif.readGameStates()


if __name__ == "__main__":
    app.config[
        'SEND_FILE_MAX_AGE_DEFAULT'] = 0  # stops the browser from caching

    socketio.run(app, host='0.0.0.0', port='5000', debug=True)
    #app.run(debug=True)
    print("server stopping")
Exemplo n.º 3
0
from __init__ import creat_app
from config import socketio, login_manager, mail, db

app = creat_app()
db.init_app(app)
socketio.init_app(app=app, cors_allowed_origins="*")
login_manager.init_app(app=app)
mail.init_app(app=app)
db.drop_all(app=app)
db.create_all(app=app)

if __name__ == '__main__':
    socketio.run(app, debug=True)
Exemplo n.º 4
0
# --- CHECK FOR BAD VALUES ---
if config.get("OMEKA_URI") is None:
    raise RuntimeError(
        f"Omeka URI is not set. Please set the value of OMEKA_URI in an environment variable."
    )
else:
    config["OMEKA_URI"] = f"http://{config['OMEKA_URI']}/api"

r = requests.get(config["OMEKA_URI"])
if r.status_code != 500:
    raise RuntimeError(
        f"Failed to connect to Omeka URI: {config['OMEKA_URI']} returned {r.status_code}"
    )

db.init_app(app)
csrf.init_app(app)
socketio.init_app(app)
migrate = Migrate(app, db)

with app.app_context():
    db.create_all()


@app.cli.command("omeka-sync")
def omeka_sync():
    sync_with_omeka()


if __name__ == "__main__":
    socketio.run(app)
Exemplo n.º 5
0
from gevent import monkey
monkey.patch_all()

import sys
from config.loader import neo_config
from config import create_app, socketio, NeoAPI, sockets

if __name__ == '__main__':
    if neo_config.load_config():
        neo_config.set_project_variables()
        app = create_app(neo_config)
        socketio.run(app=app,
                     port=neo_config.port,
                     host=neo_config.host,
                     debug=neo_config.debug)
        sys.exit(0)
    else:
        print("An error occured loading the configuration file",
              file=sys.stderr)
        sys.exit(1)