Spaces:
Runtime error
Runtime error
from flask import Flask, request, Response | |
import requests | |
import json | |
import datetime | |
import os | |
from PyDeepLX import PyDeepLX | |
app = Flask(__name__) | |
def proxy(): | |
# ์ธ๋ถ์์ ๋ค์ด์จ POST ์์ฒญ์ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ | |
request_data = request.get_data() | |
access_token = request.headers.get('Authorization') | |
if access_token != f'Bearer {os.environ["ACCESS_TOKEN"]}': | |
return Response(status=401) | |
else: | |
translated_sentence = PyDeepLX.translate(request_data["text"], request_data["source_lang"], request_data["target_lang"]) | |
temp_res = {"alternatives": [], "code": 200, "data": translated_sentence, "source_lang": request_data["source_lang"], "target_lang": request_data["target_lang"]} | |
return jsonify(temp_res) | |
if __name__ == '__main__': | |
app.run(port=7860) | |