Unity???Flask??????а???
???????????? ???????[ 2015/3/5 16:17:29 ] ??????????????? ??????? ????
???????????С????????а???????PlayerPrefs?洢????????????????????????????????????????????С???????Flask??????
?????л????????????URL?????????а????????????score??????????REST???????????URL???/scores????GET??????а????????POST???????????????а?????????????????а?????????????o??????
????Flask????????REST??????????????route??method??????????洴????????汾??rank_server.py???????????Rails??????
????from flask import Flask
????app = Flask(__name__)
????@app.route('/scores'?? methods=['GET'])
????def index():
????return 'index'
????@app.route('/scores'?? methods=['POST'])
????def create():
????return 'create'
????if __name__ == '__main__':
????app.run(debug=True)
???????python rank_server.py???????????????????????????cURL????????á?
????brew install curl
????????GET??
????`curl -i -X GET 127.0.0.1:5000/scores`
????????POST??
????`curl -i -X POST 127.0.0.1:5000/scores`
????-i???????????????????????????debug??-X???????????????method??
???????????????????
????????????????洢?????????????????????sqlite??????????mysql??
???????????create_rank.sql???????£?
????DROP TABLE IF EXISTS rank;
????CREATE TABLE rank(
????id INTEGER PRIMARY KEY AUTOINCREMENT??
????name VARCHAR(255) NOT NULL??
????score INTEGER NOT NULL
????);
????Mac???sqlite??????????????sql?????
????sqlite3 rank.db < create_rank.sql
?????????????????????????磺
????INSERT INTO rank (name?? score) VALUES ('A'?? 100);
????INSERT INTO rank (name?? score) VALUES ('B'?? 200);
????INSERT INTO rank (name?? score) VALUES ('C'?? 300);
??????????????????rank_server.py?м?????????δ????????????????????????????
????import sqlite3
????DATABASE = 'rank.db'
????@app.before_request
????def before_request():
????g.db = sqlite3.connect(DATABASE)
????@app.teardown_request
????def teardown_request(exception):
????if hasattr(g?? 'db'):
????g.db.close()
????????漲???????????????JSON?????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11