39 lines
903 B
Python
39 lines
903 B
Python
import json
|
|
from flask import Flask, send_from_directory, jsonify
|
|
import random
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
###############################################################################
|
|
# SVELTE 'STATIC' BACKEND. Always send index.html and the requested js-files. (compiled by npm)
|
|
|
|
@app.route("/") #index.html
|
|
def base():
|
|
return send_from_directory('../client/public', 'index.html')
|
|
@app.route("/<path:path>") #js-files
|
|
def home(path):
|
|
return send_from_directory('../client/public', path)
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
# API for news_check.
|
|
|
|
@app.route("/api/article/<int:id>/get")
|
|
def get_article(id):
|
|
res = {"value": id}
|
|
return jsonify(res)
|
|
|
|
@app.route("/api/article/<int:id>/set", methods=['POST'])
|
|
def set_article(id):
|
|
return str(random.randint(0, 100))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0", port="80")
|