-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
38 lines (31 loc) · 1.24 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask
from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy
from flask_jwt_extended import JWTManager
app = Flask(__name__)
api = Api(app)
# connect to database
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = 'some-secret-string'
db = SQLAlchemy(app)
#create database if not exist
@app.before_first_request
def create_tables():
db.create_all()
app.config['JWT_SECRET_KEY'] = 'jwt-secret-string'
#app.config['JWT_BLACKLIST_ENABLED'] = True
#app.config['JWT_BLACKLIST_TOKEN_CHECKS'] = ['access', 'refresh']
jwt = JWTManager(app)
import views, models, resources
api.add_resource(resources.UserRegistration, '/registration')
api.add_resource(resources.UserLogin, '/login')
api.add_resource(resources.UserLogoutAccess, '/logout/access')
api.add_resource(resources.UserLogoutRefresh, '/logout/refresh')
api.add_resource(resources.TokenRefresh, '/token/refresh')
api.add_resource(resources.AllUsers, '/users')
#api.add_resource(resources.SecretResource, '/secret')
#@jwt.token_in_blacklist_loader
#def check_if_token_in_blacklist(decrypted_token):
# jti = decrypted_token['jti']
# return models.RevokedTokenModel.is_jti_blacklisted(jti)