-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
executable file
·32 lines (26 loc) · 846 Bytes
/
Copy pathindex.py
File metadata and controls
executable file
·32 lines (26 loc) · 846 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
from flask import Flask, request, render_template, send_file
from google.cloud import translate
import requests
app = Flask(__name__)
# default route
@app.route('/')
def home():
client = translate.Client()
languages = client.get_languages()
return render_template('lang-dropdown.html', languages=languages)
@app.route('/submit')
def submit():
lang = request.args.get('lang')
hello = requests.get('http://translate-service/hello/' + lang)
return render_template('hello.html', helloworld=hello.text)
@app.route('/health')
def health():
return 'healthly'
@app.route("/image/<filename>")
def get_image(filename):
return send_file(filename, mimetype='image/jpg')
@app.errorhandler(404)
def not_found(error):
return render_template('404.html')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5002)