49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
from flask import request, jsonify, Flask
|
|
from flask.json import JSONEncoder
|
|
from datetime import date
|
|
import modules.db_connect
|
|
|
|
|
|
class MyJSONEncoder(JSONEncoder):
|
|
def default(self, o):
|
|
if isinstance(o, date):
|
|
return o.isoformat()
|
|
|
|
return super().default(o)
|
|
|
|
|
|
class MyFlask(Flask):
|
|
json_encoder = MyJSONEncoder
|
|
|
|
|
|
app = MyFlask(__name__)
|
|
modules.db_connect.init()
|
|
import modules.gamelist # noqa: E402
|
|
import modules.game # noqa: E402
|
|
|
|
# Important initialization stuff
|
|
config = modules.db_connect.config
|
|
|
|
|
|
# Just a simple homepage, nothing fancy
|
|
@app.route('/', methods=['GET'])
|
|
def home():
|
|
if 'id' not in request.args:
|
|
return "<h1>BCNS Game Distribution System</h1><p>API-endpoint</p>"
|
|
else:
|
|
return jsonify("I see you're a man of culture as well")
|
|
|
|
|
|
# Fetch a list of one users owned vehicles
|
|
@app.route('/<userid>/vehiclelist', methods=['GET'])
|
|
def user_vehiclelist(userid):
|
|
|
|
return False
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.config['JSON_AS_ASCII'] = False
|
|
app.run(
|
|
host=config.get('Running', 'host'),
|
|
port=config.get('Running', 'Port'))
|