File size: 983 Bytes
12be43b
6ec1649
12be43b
 
 
 
e3cd3c2
12be43b
6ec1649
 
 
 
 
 
 
 
 
e3cd3c2
 
 
e61f9fd
 
3f13d2a
b1687d7
e3cd3c2
 
 
c5ffb47
6ec1649
 
c31ffcf
c5ffb47
12be43b
6ec1649
b6a5540
c31ffcf
 
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
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!!!