Example #1
0
    url_for,
    abort,
    render_template,
    flash,
    Response,
    send_from_directory,
)
import time
from bluepy import btle
import logging
import server_settings

app = Flask(__name__)
app.config.from_object(__name__)
# WARNING: For some reason, setting Flask DEBUG=True causes btle to fail
app.config["PROPOGATE_EXCEPTIONS"] = True

# Log to stdout
logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s]  %(message)s")
rootLogger = logging.getLogger()
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(logFormatter)
rootLogger.addHandler(consoleHandler)

notification_data = False  # Buffer to store data from BTLE. False if nothing yet read or data already read
temperature = None  # None if not yet loaded
visor_status = None

debug = True

response_prefix = """
Example #2
0

def get_player_history(user_id):

    try:

        return request_generator("IPlayerService/GetRecentlyPlayedGames/v0001/", {"steamid": user_id, "format": "json"})

    except Exception as e:
        print e


@application.route("/api/generate_steam_badge/<user_id>/")
def generate_steam_badge(user_id):
    try:

        user_response = get_user(user_id)
        play_history_response = get_player_history(user_id)

        response = {"user_details": json.loads(user_response), "play_history": json.loads(play_history_response)}

        return jsonify(**response)

    except Exception as e:
        print e


if __name__ == "__main__":
    application.config.from_object("config")
    application.config["PROPOGATE_EXCEPTIONS"] = True
    application.run(host="0.0.0.0", debug=True)