This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import api_root | |
from flask_restful import Resource, marshal_with, fields | |
class IPField(fields.Raw): | |
def format(self, value): | |
parts = value.split('.') | |
parts[1] = '***' | |
return '.'.join(parts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import api_root | |
from flask_restful import Resource, marshal_with, fields | |
class IPField(fields.Raw): | |
def format(self, value): | |
parts = value.split('.') | |
parts[1] = '***' | |
return '.'.join(parts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import api_root | |
from flask_restful import Resource, marshal_with, fields | |
class IPField(fields.Raw): | |
def format(self, value): | |
parts = value.split('.') | |
parts[1] = '***' | |
return '.'.join(parts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import api_root | |
from flask_restful import Resource, marshal_with, fields | |
class IPField(fields.Raw): | |
def format(self, value): | |
parts = value.split('.') | |
parts[1] = '***' | |
return '.'.join(parts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import api_root | |
from flask_restful import Resource, marshal_with, fields | |
class IPField(fields.Raw): | |
def format(self, value): | |
parts = value.split('.') | |
parts[1] = '***' | |
return '.'.join(parts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import api_root | |
from flask_restful import Resource, marshal_with, fields | |
class IPField(fields.Raw): | |
def format(self, value): | |
parts = value.split('.') | |
parts[1] = '***' | |
return '.'.join(parts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import api_root | |
from flask_restful import Resource | |
@api_root.resource('/documents') | |
class DocumentListAPI(Resource): | |
def get(self): | |
items = [ | |
{'id': 1, 'title': 'title1', 'content': 'content1', 'ip': '1.2.3.4'}, | |
{'id': 2, 'title': 'title2', 'content': 'content2', 'ip': '5.6.7.8'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import api_root | |
from flask_restful import Resource | |
@api_root.resource('/documents') | |
class DocumentListAPI(Resource): | |
def get(self): | |
items = [ | |
{'id': 1, 'title': 'title1', 'content': 'content1', 'ip': '1.2.3.4'}, | |
{'id': 2, 'title': 'title2', 'content': 'content2', 'ip': '5.6.7.8'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def refreshing_oauth_token(): | |
form_data = { | |
'grant_type': 'refresh_token', | |
'client_id': app.config.get('OAUTH_CLIENT_ID'), | |
'client_secret': app.config.get('OAUTH_CLIENT_SECRET'), | |
'refresh_token': REFRESH_TOKEN | |
} | |
response = RequestOauth.get_token(form_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.errorhandler(401) | |
def unauthorized(e): | |
# 토큰이 만료된 경우에는 일단 토큰 재발급을 시도해본다 | |
if e.description == 'expired': | |
return refreshing_oauth_token() | |
elif e.description == 'permission_required': | |
return render_template('error/error.html', | |
data={ | |
'title': '401!!', | |
'header': '권한이 없어요!', |