-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (30 loc) · 984 Bytes
/
app.py
File metadata and controls
47 lines (30 loc) · 984 Bytes
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
35
36
37
38
39
40
41
42
43
44
45
46
import json
import flask.cli
from flask import Flask, request, Response, render_template, jsonify
import requests
import random
app = Flask(__name__, static_url_path='/static')
@app.route("/kogpt2", methods=["POST"])
def gpt2():
context = request.form['context']
headers = {'Content-Type': 'application/json; charset=\'utf-8\''}
num_samples = 1
length = 300
data = {
"text": context,
"num_samples": num_samples,
"length": length
}
response = requests.post('https://train-kovgd07j8yvco5i03qo3-gpt2-train-teachable-ainize.endpoint.ainize.ai/predictions/gpt-2-ko-small-finetune',headers=headers,json=data)
res = response.json()
return jsonify(res)
@app.route("/")
def main():
return render_template("index.html")
# Health Check
@app.route("/healthz", methods=["GET"])
def healthCheck():
return "", 200
if __name__ == "__main__":
from waitress import serve
serve(app, host='0.0.0.0', port=5000)