기타 개선
This commit is contained in:
27
app/main.py
27
app/main.py
@ -8,25 +8,32 @@ toonat = DaminationAPI()
|
||||
app = web.Application()
|
||||
|
||||
|
||||
@routes.get('/get_subscriber')
|
||||
@routes.get('/get_subscriber/{widget_id}')
|
||||
async def get_widgets(request):
|
||||
subscribers = toonat.get_subscribers()
|
||||
widget_id = request.match_info['widget_id']
|
||||
subscribers = toonat.get_subscribers(widget_id)
|
||||
return web.json_response(subscribers)
|
||||
|
||||
@routes.get('/subscribe/{widget_id}/{url}')
|
||||
@routes.get('/subscribe/{widget_id}')
|
||||
async def subscribe(request):
|
||||
"""
|
||||
주어진 widget_id와 url로 구독을 추가합니다.
|
||||
"""
|
||||
widget_id = request.match_info['widget_id']
|
||||
url = request.match_info['url']
|
||||
url = request.query['url']
|
||||
success = toonat.add_subscriber(widget_id, url)
|
||||
if success:
|
||||
return web.Response(text=f"Subscribed to widget ID {widget_id} with URL {url}.")
|
||||
else:
|
||||
return web.Response(text=f"Already subscribed to widget ID {widget_id} with URL {url}.")
|
||||
|
||||
@routes.get('/unsubscribe/{widget_id}/{url}')
|
||||
@routes.get('/unsubscribe/{widget_id}')
|
||||
async def unsubscribe(request):
|
||||
"""
|
||||
주어진 widget_id와 url로 구독을 취소합니다.
|
||||
"""
|
||||
widget_id = request.match_info['widget_id']
|
||||
url = request.match_info['url']
|
||||
url = request.query['url']
|
||||
success = toonat.remove_subscriber(widget_id, url)
|
||||
if success:
|
||||
return web.Response(text=f"Unsubscribed from widget ID {widget_id} with URL {url}.")
|
||||
@ -42,23 +49,23 @@ async def get_widgets(request):
|
||||
return web.json_response(widget_ids)
|
||||
|
||||
|
||||
@routes.get('/add_widget/{widget_id}')
|
||||
@routes.get('/add_widget')
|
||||
async def add_widget(request):
|
||||
"""
|
||||
주어진 widget_id를 위젯 ID 목록에 추가하고 알림을 가져오는 작업을 시작하는 웹 API 엔드포인트입니다.
|
||||
widget_id: 추가할 위젯 ID
|
||||
"""
|
||||
widget_id = request.match_info['widget_id']
|
||||
widget_id = request.query['widget_id']
|
||||
await toonat.add_widget_and_start_fetching_notifications(widget_id)
|
||||
return web.Response(text=f"Widget ID {widget_id} added and fetching started.")
|
||||
|
||||
@routes.get('/remove_widget/{widget_id}')
|
||||
@routes.get('/remove_widget')
|
||||
async def remove_widget(request):
|
||||
"""
|
||||
주어진 widget_id를 위젯 ID 목록에서 제거하고 알림을 가져오는 작업을 중단하는 웹 API 엔드포인트입니다.
|
||||
widget_id: 제거할 위젯 ID
|
||||
"""
|
||||
widget_id = request.match_info['widget_id']
|
||||
widget_id = request.query['widget_id']
|
||||
await toonat.remove_widget_and_stop_fetching_notifications(widget_id)
|
||||
return web.Response(text=f"Widget ID {widget_id} removed and fetching stopped.")
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
MAX_RETRIES=3
|
||||
|
||||
[widget]
|
||||
ids=
|
||||
ids=2af1686a0f9e397359986a0091e2d6a3,37c825512fe1c3473dd3b47eea3f5368
|
||||
|
||||
[server]
|
||||
ip=192.168.1.210
|
||||
|
||||
Reference in New Issue
Block a user