import time
from datetime import date, timedelta
+from json import loads
+from requests import post
+
db.init_db()
app = Flask(__name__)
CORS(app, supports_credentials=True)
count=db.coffee_count(uid, 0),
stamp=time.time()
)
+ # TODO: Replace stamp parameter with proper cache control HTTP
+ # headers in response
return render_template('user.html', stamp=time.time())
print("Log:", data)
return data
return "nope"
+
+@app.route("/tellCoffeebot", methods=["POST"])
+def tell_coffeebot():
+ err = "Don't worry now! There is a NEW HOPE Tonda is buying NEW PACK!"
+ if request.method == "POST":
+ what = loads(request.data.decode("utf-8"))
+ try:
+ with open(".config", "r") as f:
+ conf = loads(f.read())
+ except:
+ return "Config needed! Please find in git history how it should look."
+ try:
+ res = post(conf["coffeebot"]["url"], json=what)
+ print("res is {}".format(res))
+ except:
+ err = "No connection! No covfefe! We all die here!"
+ if not res.ok:
+ err = "Slack don't like the request! It's discrimination!"
+ return err