forked from varia/multifeeder
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.0 KiB
53 lines
1.0 KiB
import flask
|
|
import feedtools
|
|
import json
|
|
|
|
APP = flask.Flask(__name__,
|
|
static_url_path="",
|
|
static_folder="static",
|
|
template_folder="templates")
|
|
|
|
@APP.route("/")
|
|
def index():
|
|
db = feedtools.load()
|
|
template = flask.render_template(
|
|
"index.html",
|
|
db=db,
|
|
)
|
|
return template
|
|
|
|
@APP.route("/API/latest/<num>")
|
|
def latest(num):
|
|
request = feedtools.latest(num)
|
|
response = APP.response_class(
|
|
response=json.dumps(request),
|
|
status=200,
|
|
mimetype='application/json'
|
|
)
|
|
return response
|
|
|
|
@APP.route("/API/today/")
|
|
def today():
|
|
request = feedtools.today()
|
|
response = APP.response_class(
|
|
response=json.dumps(request),
|
|
status=200,
|
|
mimetype='application/json'
|
|
)
|
|
return response
|
|
|
|
@APP.route("/API/past/<days>")
|
|
def past(days):
|
|
request = feedtools.past(days)
|
|
response = APP.response_class(
|
|
response=json.dumps(request),
|
|
status=200,
|
|
mimetype='application/json'
|
|
)
|
|
return response
|
|
|
|
if __name__ == "__main__":
|
|
feedtools.update()
|
|
APP.debug = True
|
|
APP.run(port=5678)
|
|
|
|
|