-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.py
42 lines (31 loc) · 868 Bytes
/
app.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__version__ = "0.0.1"
__author__ = "@lantip"
__date__ = "2020/05/11"
__description__ = "Latin to Javanese Transliterator"
"""
import os
import json
from flask import Flask, request, jsonify, render_template
from flask_cors import CORS
from latintojavanese import dotransliterate
app = Flask(__name__, template_folder="example", static_folder="example")
app.config.from_pyfile('settings.cfg')
# CORS policy
CORS(app)
@app.route('/', methods=['POST'])
def index():
text = request.form.get('text')
result = dotransliterate(text)
resp = {
'status': 'OK',
'result': result
}
return json.dumps(resp)
@app.route('/form', methods=['GET'])
def form():
return render_template('formpage.html')
if __name__ == '__main__':
app.run(app.config['DEBUG'])