create api blueprint

This commit is contained in:
Sorrel Bri 2019-10-04 15:00:47 -07:00
parent 836b0bb7dd
commit df04427ea0
20 changed files with 39 additions and 27 deletions

14
api/api.py Normal file
View file

@ -0,0 +1,14 @@
from flask import Blueprint, request, jsonify, session
from .users.user_endpoint import UserEndpoint
api = Blueprint('api', __name__, url_prefix='/api')
@api.route('/home', methods=['GET'])
def api_home():
response = {"message": "home page"}
return jsonify(response)
@api.route('/users')
def api_users():
return jsonify(UserEndpoint.users())

0
api/users/__init__.py Normal file
View file

View file

@ -0,0 +1,5 @@
class UserEndpoint(object):
def users():
response = {"message": "users page"}
return response

16
app.py
View file

@ -17,12 +17,12 @@ CORS(app)
# config database # config database
app_settings = os.getenv( app_settings = os.getenv(
'APP_SETTINGS', 'APP_SETTINGS',
'project.server.config.DevelopmentConfig' 'config.DevelopmentConfig'
) )
app.config.from_object(app_settings) app.config.from_object(app_settings)
#init bcrypt # init bcrypt
bcrypt = Bcrypt(app) bcrypt = Bcrypt(app)
# init database # init database
@ -32,12 +32,7 @@ db = SQLAlchemy(app)
ma = Marshmallow(app) ma = Marshmallow(app)
# init all db models # init all db models
from .models.User import User import models
from .models.GameRoom import GameRoom
from .models.TimeSettings import TimeSettings
from .models.Game import Game
from .models.Move import Move
from .models.Message import Message
migrate = Migrate(app, db) migrate = Migrate(app, db)
@ -52,7 +47,10 @@ PORT = 8000
def hello_world(): def hello_world():
return 'Hello World' return 'Hello World'
@app.route('/api') # Blue prints
from api.api import api
app.register_blueprint(api)
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -1,4 +1,4 @@
import os
# local db # local db
DATABASE = 'postgresql://localhost/browser-go' DATABASE = 'postgresql://localhost/browser-go'

6
models.py Normal file
View file

@ -0,0 +1,6 @@
from models.User import User
from models.GameRoom import GameRoom
from models.TimeSettings import TimeSettings
from models.Game import Game
from models.Move import Move
from models.Message import Message

View file

@ -1,4 +1,4 @@
from ..app import db, ma from app import db, ma
import enum import enum
class Players(enum.Enum): class Players(enum.Enum):

View file

@ -1,4 +1,4 @@
from ..app import db, ma from app import db, ma
import enum import enum
class Languages(enum.Enum): class Languages(enum.Enum):

View file

@ -1,4 +1,4 @@
from ..app import db, ma from app import db, ma
import enum import enum
class Players(enum.Enum): class Players(enum.Enum):

View file

@ -1,4 +1,4 @@
from ..app import db, ma from app import db, ma
import enum import enum
class Players(enum.Enum): class Players(enum.Enum):

View file

@ -1,4 +1,4 @@
from ..app import db, ma from app import db, ma
import enum import enum
class TimeTypes(enum.Enum): class TimeTypes(enum.Enum):

View file

@ -1,4 +1,4 @@
from ..app import db, ma, bcrypt from app import db, ma, bcrypt
import datetime import datetime
import enum import enum

View file

@ -1,11 +0,0 @@
from flask import Blueprint
user = Blueprint('users', __name__)
@user.route('/<int:user_id>')
def func():
pass
@user.route('/<str:user_username>')
def func():
pass