binqiangliu commited on
Commit
f1d9208
·
1 Parent(s): c31ffcf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import flask
2
+ from flask import Flask, request, jsonify
3
+ import os
4
+ from dotenv import load_dotenv
5
+ load_dotenv()
6
+
7
+ app = flask.Flask(__name__, template_folder="./")
8
+
9
+ # 定义API端点
10
+ #app = Flask(__name__)
11
+ #@app.route('/', methods=['POST'])
12
+ #def home_api():
13
+ #...
14
+ # return {"Message":"Flask Home API Deploy Success on HF"}
15
+ #@app.route('/api/chat', methods=['POST'])
16
+ #...
17
+
18
+ @app.route('/')
19
+ def index():
20
+ return flask.render_template('index.html')
21
+
22
+ #app = Flask(__name__)
23
+ @app.route('/api/chat', methods=['POST'])
24
+ def chat():
25
+ data = request.get_json()
26
+ user_query = data['user_question']
27
+ print(user_query)
28
+ initial_response="hello"
29
+ #return jsonify({'response': initial_response})
30
+ return {'response': initial_response}
31
+ #Working!!!
32
+
33
+ if __name__ == '__main__':
34
+ #app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
35
+ #app.run(host='0.0.0.0', port=7860)
36
+ app.run(host='0.0.0.0', port=7860)
37
+ #Working!!!