File size: 641 Bytes
ee3a6ac
 
a746d34
 
 
ee3a6ac
 
 
a746d34
 
ee3a6ac
9df0420
a746d34
 
 
 
 
 
 
 
 
 
 
ee3a6ac
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flask import Flask, request, jsonify
import pytesseract
from PIL import Image
import gradio as gr
from plantuml import PlantUML

app = Flask(__name__)

# Initialize PlantUML
plantuml = PlantUML()

@app.route('/ocr', methods=['POST'])
def ocr():
    img = request.files['image']
    img.save('temp.jpg')
    text = pytesseract.image_to_string(Image.open('temp.jpg'))
    return jsonify({'text': text})

@app.route('/plantuml', methods=['POST'])
def plantuml_diagram():
    code = request.form['code']
    diagram = plantuml.get_svg_string(code)
    return jsonify({'diagram': diagram})

if __name__ == '__main__':
    app.run(debug=True)