add room endpoints
This commit is contained in:
parent
2daacc05c9
commit
2bafe9102c
4 changed files with 37 additions and 13 deletions
22
api/api.py
22
api/api.py
|
@ -1,5 +1,6 @@
|
|||
from flask import Blueprint, request, jsonify, session
|
||||
from .users.user_endpoint import UserEndpoint
|
||||
from .users.room_endpoint import RoomEndpoint
|
||||
|
||||
api = Blueprint('api', __name__, url_prefix='/api')
|
||||
|
||||
|
@ -8,10 +9,23 @@ def api_home():
|
|||
response = {"message": "home page"}
|
||||
return jsonify(response)
|
||||
|
||||
@api.route('/users')
|
||||
def api_users():
|
||||
@api.route('/users', methods=['GET'])
|
||||
def api_get_users():
|
||||
return jsonify(UserEndpoint.users())
|
||||
|
||||
@api.route('/user')
|
||||
def api_user():
|
||||
@api.route('/user', methods=['GET'])
|
||||
def api_get_user():
|
||||
return jsonify(UserEndpoint.user())
|
||||
|
||||
@api.route('/rooms', methods=['GET'])
|
||||
def api_get_rooms():
|
||||
return RoomEndpoint.get_rooms()
|
||||
|
||||
@api.route('/room', methods=['GET'])
|
||||
def api_get_room():
|
||||
return RoomEndpoint.get_room()
|
||||
|
||||
# protected route
|
||||
@api.route('/room', methods=['POST'])
|
||||
def api_post_room():
|
||||
return pass
|
|
@ -1,7 +0,0 @@
|
|||
from flask import Blueprint
|
||||
|
||||
room = Blueprint('rooms', __name__)
|
||||
|
||||
@room.route('/<int:room_id>')
|
||||
def func():
|
||||
pass
|
9
api/rooms/room_endpoint.py
Normal file
9
api/rooms/room_endpoint.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from models.User import User, user_schema, users_schema
|
||||
from models.Room import Room
|
||||
from flask import request, jsonify, Response, json
|
||||
|
||||
class RoomEndpoint(object):
|
||||
def get_rooms():
|
||||
pass
|
||||
def get_room():
|
||||
pass
|
|
@ -9,9 +9,17 @@ def handle_connection():
|
|||
|
||||
cool
|
||||
''')
|
||||
send({'data':'connection'})
|
||||
emit('message', {'data':'connection'})
|
||||
|
||||
@socketio.on('message')
|
||||
def handle_message(message):
|
||||
print(message)
|
||||
emit('message return', {'data':'a message was sent'})
|
||||
emit('message return', {'message':'a message was sent'}, broadcast=True)
|
||||
|
||||
@socketio.on('connect', namespace='/newroom')
|
||||
def handle_connection():
|
||||
print('''
|
||||
|
||||
look cool a namespaced socketio connection!
|
||||
|
||||
''')
|
Loading…
Reference in a new issue