-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
49 lines (42 loc) · 1.33 KB
/
app.py
File metadata and controls
49 lines (42 loc) · 1.33 KB
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
39
40
41
42
43
44
45
46
47
48
49
from flask import Flask
from flask_jwt_extended import JWTManager
from flasgger import Swagger
from config import Config
from extensions import db
import yaml
from flask_cors import CORS
from auth.jwt import auth_bp
from controllers.comanda_ctrl import comanda_bp
from controllers.usuario_ctrl import usuario_bp
app = Flask(__name__)
app.config.from_object(Config)
db.init_app(app)
jwt = JWTManager(app) # Aqui ativa o JWT na aplicação
app.config['SWAGGER'] = {
'title': 'Minha API',
'uiversion': 3,
'securityDefinitions': {
'BearerAuth': {
'type': 'apiKey',
'name': 'Authorization',
'in': 'header',
'description': 'Insira seu token JWT no formato **Bearer <seu_token>**'
}
},
'security': [
{
'BearerAuth': []
}
]
}
with open('swagger/swagger.yaml', 'r', encoding='utf-8') as f:
swagger_template = yaml.safe_load(f)
swagger = Swagger(app, template=swagger_template)
app.register_blueprint(usuario_bp, url_prefix='/RestAPIFurb')
app.register_blueprint(auth_bp, url_prefix='/RestAPIFurb')
app.register_blueprint(comanda_bp, url_prefix='/RestAPIFurb')
CORS(app)
if __name__ == '__main__':
with app.app_context():
db.create_all()
app.run(debug=True, port=8080)