Spaces:
Runtime error
Runtime error
Commit ·
6ec1649
1
Parent(s): 365f81a
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,32 @@
|
|
| 1 |
import flask
|
| 2 |
-
from flask import request
|
| 3 |
import os
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
load_dotenv()
|
| 6 |
|
| 7 |
app = flask.Flask(__name__, template_folder="./")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
@app.route('/')
|
| 10 |
def index():
|
| 11 |
-
return flask.render_template('index.html')
|
| 12 |
-
|
| 13 |
#app = flask(__name__)
|
| 14 |
@app.route('/api/chat', methods=['POST'])
|
| 15 |
def chat():
|
| 16 |
incoming = request.get_json()
|
| 17 |
print(incoming)
|
| 18 |
initial_response="hello"
|
| 19 |
-
return jsonify({'response': initial_response})
|
|
|
|
| 20 |
|
| 21 |
if __name__ == '__main__':
|
| 22 |
-
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
|
|
|
|
|
| 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 |
#app = flask(__name__)
|
| 22 |
@app.route('/api/chat', methods=['POST'])
|
| 23 |
def chat():
|
| 24 |
incoming = request.get_json()
|
| 25 |
print(incoming)
|
| 26 |
initial_response="hello"
|
| 27 |
+
#return jsonify({'response': initial_response})
|
| 28 |
+
return {'response': initial_response}
|
| 29 |
|
| 30 |
if __name__ == '__main__':
|
| 31 |
+
#app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
| 32 |
+
app.run(host='0.0.0.0', port=7860)
|