flask_inference_api / app-Original.py
binqiangliu's picture
Rename app.py to app-Original.py
c31ffcf
raw
history blame contribute delete
983 Bytes
import flask
from flask import Flask, request, jsonify
import os
from dotenv import load_dotenv
load_dotenv()
#app = flask.Flask(__name__, template_folder="./")
# 定义API端点
#app = Flask(__name__)
#@app.route('/', methods=['POST'])
#def home_api():
#...
# return {"Message":"Flask Home API Deploy Success on HF"}
#@app.route('/api/chat', methods=['POST'])
#...
#@app.route('/')
#def index():
# return flask.render_template('index.html')
app = Flask(__name__)
@app.route('/api/chat', methods=['POST'])
def chat():
data = request.get_json()
user_query = data['user_question']
print(user_query)
initial_response="hello"
#return jsonify({'response': initial_response})
return {'response': initial_response}
#Working!!!
if __name__ == '__main__':
#app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
#app.run(host='0.0.0.0', port=7860)
app.run(host='0.0.0.0', port=7860)
#Working!!!