from flask import request, jsonify, Flask import json from datetime import date import tomllib import os class MyJSONEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, date): return o.isoformat() return super().default(o) def create_app(test_config=None): app = Flask(__name__, instance_relative_config=True) app.config['JSON_AS_ASCII'] = False if test_config is None: app.config.from_file('bcnsgdsapi-config.toml', load=tomllib.load, text=False) else: app.config.from_mapping(test_config) try: os.makedirs(app.instance_path, exist_ok=True) except OSError: print( "Error: instance path not found!" + " No configuration file has been loaded") pass import bcnsGDSAPI.modules.db_connect bcnsGDSAPI.modules.db_connect.init(app.config) from bcnsGDSAPI.modules.gamelist import gamelist from bcnsGDSAPI.modules.game import game app.register_blueprint(gamelist) app.register_blueprint(game) # Just a simple homepage, nothing fancy @app.route('/', methods=['GET']) def home(): if 'id' not in request.args: return "

BCNS Game Distribution System

API-endpoint

" else: return jsonify("I see you're a man of culture as well") return app if __name__ == "__main__": app = create_app() app.run(host="0.0.0.0", port=8001, debug=True)