27 lines
792 B
Python
27 lines
792 B
Python
|
from __future__ import annotations
|
||
|
import json
|
||
|
from flask_restful import Resource
|
||
|
from flask import current_app as app, jsonify, request
|
||
|
from typing import TYPE_CHECKING
|
||
|
|
||
|
if TYPE_CHECKING:
|
||
|
from modules.Archive.database import Database
|
||
|
|
||
|
class Archive_GetPost(Resource):
|
||
|
def get(self, id):
|
||
|
id = int(id)
|
||
|
db : Database = app.databases["Archive"]
|
||
|
|
||
|
result = db.get_post(id)
|
||
|
|
||
|
if result is None:
|
||
|
response = app.response_class(status=404)
|
||
|
else:
|
||
|
response = app.response_class(
|
||
|
response=json.dumps(result, ensure_ascii=False, indent=1),
|
||
|
status=200,
|
||
|
mimetype='application/json'
|
||
|
)
|
||
|
|
||
|
response.headers.add("Access-Control-Allow-Origin", "*")
|
||
|
return response
|