Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions api/general.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# This is a file that will be used to contain API's and and HTTP that require access to multiple parts of our backend
# # This is a file that will be used to contain API's and and HTTP that require access to multiple parts of our backend

from flask import Blueprint, request, jsonify, current_app, Response, g
from flask_restful import Api, Resource # used for REST API building
from datetime import datetime
from __init__ import app
from api.jwt_authorize import token_required
from model.binaryLearningGame import binaryLearningGameScores
# from flask import Blueprint, request, jsonify, current_app, Response, g
# from flask_restful import Api, Resource # used for REST API building
# from datetime import datetime
# from __init__ import app
# from api.jwt_authorize import token_required
# from model.binaryLearningGame import binaryLearningGameScores

general_api = Blueprint('general_api', __name__, url_prefix='/api')
# general_api = Blueprint('general_api', __name__, url_prefix='/api')

"""
The Api object is connected to the Blueprint object to define the API endpoints.
- The API object is used to add resources to the API.
- The objects added are mapped to code that contains the actions for the API.
- For more information, refer to the API docs: https://flask-restful.readthedocs.io/en/latest/api.html
"""
api = Api(general_api)
# """
# The Api object is connected to the Blueprint object to define the API endpoints.
# - The API object is used to add resources to the API.
# - The objects added are mapped to code that contains the actions for the API.
# - For more information, refer to the API docs: https://flask-restful.readthedocs.io/en/latest/api.html
# """
# api = Api(general_api)

class GeneralAPI:
"""
Define the API CRUD endpoints for the Post model.
There are four operations that correspond to common HTTP methods:
- post: create a new post
- get: read posts
- put: update a post
- delete: delete a post
"""
class _CRUD(Resource):
@token_required()
def get(self):
# Find all the posts by the current user
scores = binaryLearningGameScores.query.all()
# Prepare a JSON list of all the posts, uses for loop shortcut called list comprehension
json_ready = [score.read() for score in scores]
# Return a JSON list, converting Python dictionaries to JSON format
return jsonify(json_ready)
# class GeneralAPI:
# """
# Define the API CRUD endpoints for the Post model.
# There are four operations that correspond to common HTTP methods:
# - post: create a new post
# - get: read posts
# - put: update a post
# - delete: delete a post
# """
# class _CRUD(Resource):
# @token_required()
# def get(self):
# # Find all the posts by the current user
# scores = binaryLearningGameScores.query.all()
# # Prepare a JSON list of all the posts, uses for loop shortcut called list comprehension
# json_ready = [score.read() for score in scores]
# # Return a JSON list, converting Python dictionaries to JSON format
# return jsonify(json_ready)


"""
Map the _CRUD class to the API endpoints for /post.
- The API resource class inherits from flask_restful.Resource.
- The _CRUD class defines the HTTP methods for the API.
"""
api.add_resource(_CRUD, '/general/binaryScores')
# """
# Map the _CRUD class to the API endpoints for /post.
# - The API resource class inherits from flask_restful.Resource.
# - The _CRUD class defines the HTTP methods for the API.
# """
# api.add_resource(_CRUD, '/general/binaryScores')
5 changes: 1 addition & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@
from api.vote import vote_api
from api.lgate import lgate_api
# New API's being tested
from api.general import general_api
# from api.general import general_api
from api.binaryLearningGame import binaryLearningGameScores_api
from api.student import student_api
from api.binaryConverter import binary_converter_api
from api.vote import vote_api

# database Initialization functions
from model.quizgrading import quizgrading
from model.carChat import CarChat
from model.user import User, initUsers
from model.section import Section, initSections
from model.group import Group, initGroups
Expand All @@ -66,7 +64,6 @@
# apis under development
app.register_blueprint(binaryLearningGameScores_api)
app.register_blueprint(student_api)
app.register_blueprint(quizgrading_api)
app.register_blueprint(commentsAndFeedback_api)

app.register_blueprint(binary_converter_api)
Expand Down
Loading