-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapp.py
34 lines (23 loc) · 965 Bytes
/
app.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
from flask import Flask, Response, request
from ad.implementations import get_detail_ads, get_full_ads_debug
app = Flask(__name__)
@app.route('/detail-rss')
def detail_rss():
data = get_detail_ads(
tag=request.args.get('tag'), stop_words=request.args.getlist('sw')
)
return Response(data, headers={'Content-Type': 'application/rss+xml'})
@app.route('/debug-template')
def debug_template():
data = get_full_ads_debug(
tag=request.args.get('tag'), stop_words=request.args.getlist('sw')
)
return Response(data, headers={'Content-Type': 'application/rss+xml'})
@app.route('/debug-html')
def debug_html():
from ad.adapters.presenter import _get_detail
from ad.adapters.repository import GetDebugRepo
data = _get_detail(GetDebugRepo().get_all()[0])
return Response(data, headers={'Content-Type': 'text/html; charset=UTF-8'})
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=False, port=8000)