This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
65 lines (57 loc) · 2.67 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import json
import copy
import uuid
from flask import request, jsonify, send_file
from config import db, app
from bson import json_util
from view_utils import get_headers, get_default_options_response
from users import users_blueprint
from characters import characters_blueprint
from cards import cards_blueprint
from worlds import worlds_blueprint
from ud import ud_blueprint
from items import items_blueprint
from actions import actions_blueprint
app.register_blueprint(users_blueprint)
app.register_blueprint(characters_blueprint, url_prefix='/characters')
app.register_blueprint(cards_blueprint, url_prefix='/cards')
app.register_blueprint(worlds_blueprint, url_prefix='/worlds')
app.register_blueprint(ud_blueprint, url_prefix='/ud')
app.register_blueprint(items_blueprint, url_prefix='/items')
app.register_blueprint(actions_blueprint, url_prefix='/actions')
@app.route("/.well-known/games-commons-configuration/")
def games_commons_configuration():
return jsonify({
"actionDiscovery": "https://simpolis.gamescommons.com/act/discover/"
}), 200, get_headers({'Content-Type': 'application/json'})
@app.route("/act/discover/", methods=["POST"])
def action_discovery():
jsonld = copy.deepcopy(request.get_json())
return jsonify(json.loads(json_util.dumps(db.recipes.find(jsonld["target"]))))
@app.route("/")
def main():
return "Hello world!", 200
@app.route("/images/<image_path>")
def image_uploaded(image_path):
return send_file(f"./images/{image_path}", mimetype='image/png'), 200, get_headers()
@app.route("/ink/<file_path>")
def ink_uploaded(file_path):
return send_file(f"./ink/{file_path}", mimetype='application/inkml+xml'), 200, get_headers()
@app.route("/content/sceneDescription/", methods=["POST", "OPTIONS"])
def scene_description():
if request.method == 'OPTIONS':
return get_default_options_response(request)
# TODO: include the agent who is perceiving the object
return jsonify({
"@context": {
"mudcontent":"https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mudcontent.ttl#"
},
"@id": "_CharacterSees",
"mudcontent:sees": {
"@id": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/examples/mudContentDescription.json",
"@type": "https://raw.githubusercontent.com/Multi-User-Domain/vocab/main/mudcontent.ttl#Content",
"mudcontent:describes": "https://example.com/queenAnnesRevenge/",
"mudcontent:hasText": "The Queen Anne's Revenge is an elegant sloop, swift and mouverable",
"mudcontent:hasImage": "https://example.com/queenAnnesRevenge/"
}
}), 200, get_headers({'Content-Type': 'application/ld+json'})