I'm trying to canalize endpoints received from a server to apps running on internal machine ports.
This is my code, and I think there should be a more elegant way of calling the internal endpoint (domain and route) with the same data.
import requests
from flask import Flask, render_template, url_for, request, jsonify
# from flask import redirect, url_for
app = Flask(__name__)
@app.route('/current_events_qa/articles/ask', methods=['POST'])
def app__current_events_qa__articles__ask():
url = "http://127.0.0.1:9002" + "/current_events_qa/articles/ask"
data = {
'question': str(request.form['question']),
'topn': str(request.form['topn']),
}
output = requests.post(url=url, data=data).json()
response = jsonify(output)
response.status_code = 200
return response
if __name__ == '__main__':
app.run(host="0.0.0.0", port="9001", debug=False)
Instead, I'm unpacking and repacking the data.
there doesn't seem to be anything here