OSDN Git Service

403ec516ab1f1a8b7be1b3858e594571bba8ec84
[ti2/ti2.git] / api_server.py
1 # vim: tabstop=4 shiftwidth=4 softtabstop=4
2 # -*- coding: utf-8 -*-
3 #
4
5 from flask import Flask
6 from linkpair.exporter.JSON import JsonExporter
7
8 app = Flask(__name__)
9 util = None
10 collect_func = None
11
12
13 def parse_linkpair_records():
14     linkpairs = collect_func()
15     exporter = JsonExporter(util, linkpairs)
16     return exporter.run() + "\n"
17
18
19 def start_app(listen='localhost:23456', debug=True):
20     app.config.update(
21         DEBUG=debug,
22         SERVER_NAME=listen
23     )
24     app.run()
25
26
27 @app.route("/")
28 def index():
29     return parse_linkpair_records()