added authorization, signup, login with jwt

This commit is contained in:
2020-07-30 17:23:01 +02:00
parent ce872ffb63
commit 7d6f98ffda
7 changed files with 72 additions and 4 deletions

16
main.py
View File

@@ -1,18 +1,19 @@
import random
import time
from flask import Flask, request
from flask_cors import CORS
# from flask_restful import Api
from flask_jwt_extended import JWTManager, jwt_required
from flask_socketio import SocketIO
from database import db
app = Flask(__name__)
cors = CORS(app)
# api = Api(app)
sio = SocketIO(app, cors_allowed_origins='*')
@app.route('/')
@jwt_required
def home():
return {'url': '/', 'body': 'test body'}
@@ -39,5 +40,14 @@ def public_message(kwargs):
print(kwargs)
sio.emit('public message', kwargs)
if __name__ == '__main__':
from auth.auth import auth as auth_blueprint
app.config['JWT_SECRET_KEY'] = 'super-secret-key' # TODO FIX THIS
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
db.init_app(app)
JWTManager(app)
app.register_blueprint(auth_blueprint)
with app.app_context():
db.create_all()
sio.run(app, port=5005)