refactor
This commit is contained in:
parent
812c886517
commit
5c162dd4fb
@ -1,7 +1,8 @@
|
||||
import flask
|
||||
import os
|
||||
|
||||
from truthseeker import routes_api
|
||||
from truthseeker.routes import routes_api, routes_ui
|
||||
|
||||
|
||||
app = flask.Flask("truthseeker")
|
||||
|
||||
@ -22,8 +23,5 @@ def set_secret(app):
|
||||
set_secret(app)
|
||||
|
||||
|
||||
app.register_blueprint(routes_api.api_routes, url_prefix="/api/v1")
|
||||
|
||||
@app.route("/")
|
||||
def hello():
|
||||
return "Hello World!"
|
||||
app.register_blueprint(routes_api.routes_api, url_prefix="/api/v1")
|
||||
app.register_blueprint(routes_ui.routes_ui, url_prefix="/")
|
||||
|
@ -4,6 +4,7 @@ import jwt
|
||||
from datetime import datetime, timedelta
|
||||
import truthseeker
|
||||
|
||||
|
||||
# Map of all actively running games
|
||||
# games_list["game.game_id"]-> game info linked to that id
|
||||
games_list = {}
|
@ -1,10 +1,11 @@
|
||||
import flask
|
||||
|
||||
from truthseeker import game_functions
|
||||
from truthseeker.logic import game_logic
|
||||
|
||||
api_routes = flask.Blueprint("api", __name__)
|
||||
|
||||
@api_routes.route("/createGame")
|
||||
routes_api = flask.Blueprint("api", __name__)
|
||||
|
||||
@routes_api.route("/createGame")
|
||||
def create_game():
|
||||
username = flask.request.args.get("username")
|
||||
if username==None:
|
||||
@ -13,20 +14,20 @@ def create_game():
|
||||
|
||||
response = {}
|
||||
response["status"] = "ok"
|
||||
game = game_functions.create_game()
|
||||
game = game_logic.create_game()
|
||||
response["game_id"] = game.game_id
|
||||
owner, owner_jwt = game.set_owner(username=username)
|
||||
response["jwt"] = owner_jwt
|
||||
return response
|
||||
|
||||
@api_routes.route("/joinGame")
|
||||
@routes_api.route("/joinGame")
|
||||
def join_game():
|
||||
game_id = flask.request.args.get("game_id")
|
||||
username = flask.request.args.get("username")
|
||||
if game_id==None or username==None:
|
||||
return {"status": "error, username or game id not set"}
|
||||
|
||||
game = game_functions.get_game(game_id)
|
||||
game = game_logic.get_game(game_id)
|
||||
if game == None:
|
||||
return {"status": "error, game does not exist"}
|
||||
|
||||
@ -37,14 +38,14 @@ def join_game():
|
||||
response["jwt"] = member_jwt
|
||||
return response
|
||||
|
||||
@api_routes.route("/getGameInfo")
|
||||
@routes_api.route("/getGameInfo")
|
||||
def get_game_info(): # DEPRECATED, SHOULD BE REMOVED
|
||||
response = {}
|
||||
game_id = flask.request.args.get("game_id")
|
||||
if game_id == None:
|
||||
response["status"] = "No 'game_id' argument"
|
||||
return response
|
||||
game = game_functions.get_game_info(game_id)
|
||||
game = game_logic.get_game_info(game_id)
|
||||
if game == None:
|
||||
response["status"] = "Game {} does not exist".format(game_id)
|
||||
return response
|
||||
@ -54,3 +55,5 @@ def get_game_info(): # DEPRECATED, SHOULD BE REMOVED
|
||||
response["token"] = game.start_token
|
||||
return response
|
||||
|
||||
@routes_api.route("/needJwt")
|
||||
def get_game_info(): # DEPRECATED, SHOULD BE REMOVED
|
10
truthseeker/routes/routes_ui.py
Normal file
10
truthseeker/routes/routes_ui.py
Normal file
@ -0,0 +1,10 @@
|
||||
import flask
|
||||
|
||||
from truthseeker.logic import game_logic
|
||||
|
||||
|
||||
routes_ui = flask.Blueprint("ui", __name__)
|
||||
|
||||
@routes_ui.route("/")
|
||||
def hello():
|
||||
return "Hello World!"
|
Loading…
Reference in New Issue
Block a user