File tree 2 files changed +33
-19
lines changed
2 files changed +33
-19
lines changed Original file line number Diff line number Diff line change 5
5
from flask import Blueprint , abort , url_for
6
6
7
7
import worlds .Files
8
- from .. import cache
9
8
from ..models import Room , Seed
10
9
11
10
api_endpoints = Blueprint ('api' , __name__ , url_prefix = "/api" )
@@ -49,21 +48,4 @@ def supports_apdeltapatch(game: str):
49
48
}
50
49
51
50
52
- @api_endpoints .route ('/datapackage' )
53
- @cache .cached ()
54
- def get_datapackage ():
55
- from worlds import network_data_package
56
- return network_data_package
57
-
58
-
59
- @api_endpoints .route ('/datapackage_checksum' )
60
- @cache .cached ()
61
- def get_datapackage_checksums ():
62
- from worlds import network_data_package
63
- version_package = {
64
- game : game_data ["checksum" ] for game , game_data in network_data_package ["games" ].items ()
65
- }
66
- return version_package
67
-
68
-
69
- from . import generate , user # trigger registration
51
+ from . import generate , user , datapackage # trigger registration
Original file line number Diff line number Diff line change
1
+ from flask import abort
2
+
3
+ from Utils import restricted_loads
4
+ from WebHostLib import cache
5
+ from WebHostLib .models import GameDataPackage
6
+ from . import api_endpoints
7
+
8
+
9
+ @api_endpoints .route ('/datapackage' )
10
+ @cache .cached ()
11
+ def get_datapackage ():
12
+ from worlds import network_data_package
13
+ return network_data_package
14
+
15
+
16
+ @api_endpoints .route ('/datapackage/<string:checksum>' )
17
+ @cache .memoize (timeout = 3600 )
18
+ def get_datapackage_by_checksum (checksum : str ):
19
+ package = GameDataPackage .get (checksum = checksum )
20
+ if package :
21
+ return restricted_loads (package .data )
22
+ return abort (404 )
23
+
24
+
25
+ @api_endpoints .route ('/datapackage_checksum' )
26
+ @cache .cached ()
27
+ def get_datapackage_checksums ():
28
+ from worlds import network_data_package
29
+ version_package = {
30
+ game : game_data ["checksum" ] for game , game_data in network_data_package ["games" ].items ()
31
+ }
32
+ return version_package
You can’t perform that action at this time.
0 commit comments