<file_sep>from flask import Flask
from flask import request
import pytesseract
from PIL import Image
import requests
from io import BytesIO
import sys
from github import Github
import os

mykey = {"my_key1":"key1_value"}
port = sys.argv[1]
app = Flask(__name__)

@app.route('/postjson', methods = ['GET'])
def getJsoHandler():
    return {"values":"1234"}

@app.route('/github', methods = ['POST'])
def github():
    content = request.get_json()
    project = content["repository"]["name"]
    action = content["action"]
    title = content["issue"]["title"]
    description = content["issue"]["body"]
    number = content["issue"]["number"]
    userfull = content["repository"]["full_name"]
    tokenUser = userfull.split("/")
    user = tokenUser[0]
    if action == "opened":
        token1 = description.split("](https://user-images.githubusercontent.com")#seach url image
        textOCR = ""
        if len(token1)>1:
            datanameim = []
            datatextim = []
            n = len(token1)
            i = 0
            while i < n-1:
                token2 = token1[i+1].split(')')
                url = "https://user-images.githubusercontent.com"+token2[0]
                nameImage = token1[i].split("![") #seach name image
                datanameim.append(nameImage[1])
                response = requests.get(url)
                img = Image.open(BytesIO(response.content))
                text = pytesseract.image_to_string(img, lang='Thai',config='preserve_interword_spaces')
                datatextim.append(text)
                i = i+1
            n = len(datanameim)
            i = 0
            while i < n:
                description=description+"\n<details>\n<summary>"+datanameim[i]+"</summary>\n\n```\n"+datatextim[i]+"\n```\n\n</details>\n"
                i = i+1
            g = Github(os.environ['TOKEN'])
            repo = g.get_repo(user+"/"+project)
            repo.get_issue(int(number)).edit(body=description)
    return ""

@app.route('/postjson', methods = ['POST'])
def postJsonHandler():
    content = request.get_json()
    response = requests.get(content['url'])
    img = Image.open(BytesIO(response.content))
    text = pytesseract.image_to_string(img, lang='Thai',config='preserve_interword_spaces')
    return text

app.run(debug=True,host='0.0.0.0',port=port)
<file_sep>flask
flask_restful
pytesseract
pillow
requests
PyGithub