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

14
app.py
View file

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

View file

@ -1,4 +1,4 @@
import os
# local db
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
class Players(enum.Enum):

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
from ..app import db, ma
from app import db, ma
import 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 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