提交 1b4fd0cc 编写于 作者: Y Yu Yang

Make mnist-client can set BACKEND_URL

上级 0f7f0244
from flask import Flask, jsonify, render_template, request from flask import Flask, jsonify, render_template, request
import os
# webapp # webapp
app = Flask(__name__) app = Flask(__name__)
...@@ -6,7 +7,8 @@ app = Flask(__name__) ...@@ -6,7 +7,8 @@ app = Flask(__name__)
@app.route('/') @app.route('/')
def main(): def main():
return render_template('index.html') backend_url = os.getenv('BACKEND_URL', 'http://localhost:8000/')
return render_template('index.html', backend_url=backend_url)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -90,7 +90,7 @@ class Main { ...@@ -90,7 +90,7 @@ class Main {
} }
} }
$.ajax({ $.ajax({
url: 'http://localhost:8000/', url: BACKEND_URL,
method: 'POST', method: 'POST',
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify({"img":inputs}), data: JSON.stringify({"img":inputs}),
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
<title>MNIST</title> <title>MNIST</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
<script type="text/javascript" src="{{ url_for('static', filename='js/jquery.min.js') }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
<script type="text/javascript">
var BACKEND_URL = "{{ backend_url }}"
</script>
<script type="text/javascript" src="{{ url_for('static', filename='js/main.js') }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='js/main.js') }}"></script>
</head> </head>
<body> <body>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册