File size: 625 Bytes
03a8026
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
33
34

from flask import Flask
from generator import generation_function
from flask import request
from flask_cors import CORS
import asyncio

app = Flask(__name__)
CORS(app)


@app.route('/')
def hello():
    return 'Hello world!'


@app.route('/generate', methods=['POST'])
def generate():
    request_data = request.get_json()

    text = request_data["prompts"]

    if request_data.get("lang"):
        generated_recepie = generation_function(
            text, lang=request_data["lang"])
    else:
        generated_recepie = generation_function(text)

    return generated_recepie


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