laxsvips commited on
Commit
b91e12a
·
1 Parent(s): 2b307ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -39
app.py CHANGED
@@ -1,47 +1,50 @@
1
- from flask import Flask, jsonify, request
2
- from gameload import upload_game_docs
3
- import chat
4
- import os
5
- import dotenv
6
- import os
 
7
 
8
- app = Flask(__name__)
9
- dotenv.load_dotenv('.env')
10
- host = os.getenv('HOST')
11
- port = os.getenv('PORT')
12
 
13
- @app.route('/initialize_game', methods=['GET'])
14
- def initialize_game():
15
- inputs = request.args.to_dict()
16
- user_id = inputs['user_id']
17
- game_id = inputs['game_id']
18
- result = chat.initialize_game(user_id, game_id)
19
- response = {'role': 'assistant', 'content': result}
20
- return jsonify(response)
21
 
22
- @app.route('/start_game', methods=['GET'])
23
- def start_game():
24
- inputs = request.args.to_dict()
25
- user_id = inputs['user_id']
26
- game_id = inputs['game_id']
27
- user_input = inputs['user_input']
28
- gpt_output = chat.start_game(game_id, user_id, user_input)
29
- response = {'role': 'assistant', 'content': gpt_output}
30
- return jsonify(response)
31
 
32
- @app.route('/health_check', methods=['GET'])
33
- def health_check():
34
- response = {'message': 'Site is healthy'}
35
  return jsonify(response)
36
 
37
- @app.route('/load_game', methods=['GET'])
38
- def load_game():
39
- upload_game_docs()
40
- response = {'message': 'Game loaded'}
41
- return jsonify(response)
42
 
43
- if __name__ == '__main__':
44
- host = '0.0.0.0' # Replace with your desired host IP
45
- port = 8080 # Replace with your desired port number
 
 
 
46
 
47
- app.run(host=host, port=port)
 
1
+ # from flask import Flask, jsonify, request
2
+ # from gameload import upload_game_docs
3
+ # import chat
4
+ # import os
5
+ # import dotenv
6
+ # import os
7
+ import gradio
8
 
9
+ # app = Flask(__name__)
10
+ # dotenv.load_dotenv('.env')
11
+ # host = os.getenv('HOST')
12
+ # port = os.getenv('PORT')
13
 
14
+ # @app.route('/initialize_game', methods=['GET'])
15
+ # def initialize_game():
16
+ # inputs = request.args.to_dict()
17
+ # user_id = inputs['user_id']
18
+ # game_id = inputs['game_id']
19
+ # result = chat.initialize_game(user_id, game_id)
20
+ # response = {'role': 'assistant', 'content': result}
21
+ # return jsonify(response)
22
 
23
+ # @app.route('/start_game', methods=['GET'])
24
+ # def start_game():
25
+ # inputs = request.args.to_dict()
26
+ # user_id = inputs['user_id']
27
+ # game_id = inputs['game_id']
28
+ # user_input = inputs['user_input']
29
+ # gpt_output = chat.start_game(game_id, user_id, user_input)
30
+ # response = {'role': 'assistant', 'content': gpt_output}
31
+ # return jsonify(response)
32
 
33
+ # @app.route('/health_check', methods=['GET'])
34
+ def health_check(name):
35
+ response = {'message': 'Site is healthy ' + name}
36
  return jsonify(response)
37
 
38
+ # @app.route('/load_game', methods=['GET'])
39
+ # def load_game():
40
+ # upload_game_docs()
41
+ # response = {'message': 'Game loaded'}
42
+ # return jsonify(response)
43
 
44
+ gradio_interface = gradio.Interface(
45
+ fn=health_check,
46
+ inputs="text",
47
+ outputs="text"
48
+ )
49
+ gradio_interface.launch()
50