You've already forked KemoFureApi
							
							CORS test
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| from __future__ import annotations | ||||
| import json | ||||
| from flask_cors import cross_origin | ||||
| from flask_restful import Resource | ||||
| from flask import current_app as app, jsonify, request | ||||
| from typing import TYPE_CHECKING | ||||
| @@ -8,11 +9,12 @@ if TYPE_CHECKING: | ||||
|     from modules.Archive.database import Database | ||||
|  | ||||
| class Archive_SetAction(Resource): | ||||
|     @cross_origin(supports_credentials=True) | ||||
|     def post(self): | ||||
|         data = request.json | ||||
|         data = request.get_json() | ||||
|  | ||||
|         try: | ||||
|             bypass = "allow_override" in data and data["allow_override"] | ||||
|             bypass = ("allow_override" in data) and data["allow_override"] | ||||
|             action = data["action_taken"] | ||||
|             if "id_str" in data: | ||||
|                 id = int(data["id_str"]) | ||||
| @@ -23,6 +25,8 @@ class Archive_SetAction(Resource): | ||||
|         except Exception as e: | ||||
|             print(e) | ||||
|             response = app.response_class(response=e, status=400) | ||||
|             response.headers.add("Access-Control-Allow-Origin", "*") | ||||
|             return response | ||||
|  | ||||
|         db : Database = app.databases["Archive"] | ||||
|         query = f"UPDATE x_posts SET action_taken = {action} WHERE id = {id}" | ||||
| @@ -34,7 +38,7 @@ class Archive_SetAction(Resource): | ||||
|         response = app.response_class( | ||||
|             response=result, | ||||
|             status=200, | ||||
|             mimetype='application/json' | ||||
|             mimetype='text/plain' | ||||
|         ) | ||||
|  | ||||
|         response.headers.add("Access-Control-Allow-Origin", "*") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user