Week7 done

This commit is contained in:
bigJIU 2022-10-26 11:49:14 +08:00
parent 0004823617
commit d3a64595da
10 changed files with 41 additions and 19 deletions

5
.idea/workspace.xml generated
View File

@ -5,6 +5,7 @@
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/eval.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/eval.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/play.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/play.html" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -87,6 +88,8 @@
<workItem from="1666269906002" duration="7106000" />
<workItem from="1666331056069" duration="7259000" />
<workItem from="1666340478319" duration="84000" />
<workItem from="1666700018091" duration="3635000" />
<workItem from="1666752468427" duration="1563000" />
</task>
<servers />
</component>
@ -105,6 +108,6 @@
</option>
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1666620093891" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1666752985850" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
</component>
</project>

View File

@ -0,0 +1 @@
test2,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18,18,18,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2,2,2,2,18,18,18,18,18,2,2,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18

View File

@ -0,0 +1 @@
test2,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2,18,18,18,18,18,2,2,2,2,2,2,2,18,18,18,18,18,18,18,2,2,2,2,2,2,2,16,16,16,16,18,18,18,2,2,2,2,2,2,2,2,2,0,0,16,16,18,18,18,18,18,18,18,18,2,2,2,2,18,18,18,18,18,18,18,18,18,18,18,2,2,2,2,2,18,18,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,2,2,2,2,2,2,2,2,2,2,2,2,2

Binary file not shown.

1
evals/eval.txt Normal file
View File

@ -0,0 +1 @@
2-1

29
main.py
View File

@ -1,8 +1,11 @@
import os
from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__, static_folder='')
bufferJson = ['']
replayDataPath = "reps/"
evalDataPath = "evals/"
@app.route('/')
def index():
@ -10,11 +13,6 @@ def index():
return render_template('play.html', py2htmlstr=py2htmlstr)
@app.route('/datapage')
def datapage():
return bufferJson
@app.route('/eval')
def eval():
return render_template('eval.html')
@ -23,18 +21,25 @@ def eval():
@app.route('/', methods=['POST'])
def getJSONData():
if request.method == 'POST':
print("POST")
print("POST Game")
print(request.json)
return redirect(url_for('datapage'))
saveFile(replayDataPath, request.json[4], request.json)
return "Catch JSON Data"
@app.route('/', methods=['POST'])
@app.route('/eval', methods=['POST'])
def getRadioData():
if request.method == 'POST':
print("POST")
print("POST Eval")
print(request.json)
return redirect(url_for('datapage'))
saveFile(evalDataPath,"eval",request.json[0]+request.json[1]+request.json[2])
return "catch Radio"
def saveFile(path,filename,content):
file_dir = os.path.join(os.getcwd(), path)
file_path = os.path.join(file_dir, filename+".txt")
f = open(file_path, "w", encoding="utf8")
f.write(content)
f.close()
if __name__ == '__main__':
app.debug = True

1
reps/1.txt Normal file
View File

@ -0,0 +1 @@
test1,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2

1
reps/2.txt Normal file
View File

@ -0,0 +1 @@
test2,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,18,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,18,18,18,18,0,0,0,0,0,0,0,0,0,0,0,18,18,18,18,18,18,18,18,18,18,18,18,2,2,2,2,2,2,2,2,18,18,18,18,18,2,2,2,2,2,2,2,2,18,18,18,18,18,18,2,2,2,2,2,2,2,2,2,2,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,2,1

View File

@ -101,6 +101,17 @@
}
}
}
function PostToServer(data) {
var httpRequest = new XMLHttpRequest();//第一步:建立所需的对象
httpRequest.open("POST",""); //调用AddDataToServer
httpRequest.setRequestHeader("Content-Type", "application/json"); //设置请求头信息
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
//alert('添加成功');
}
}
httpRequest.send(JSON.stringify(data)); //设置为发送给服务器数据
}
window.onload=function(){
closeReplayWindow();
}
@ -153,7 +164,7 @@
var obj = document.getElementsByName("fun");
for(var i=0; i<obj.length; i ++){
if(obj[i].checked){
PostToServer(obj[i].value);
alert(obj[i].value);
}
}

View File

@ -11,7 +11,7 @@
return returnVal.then(function(){
console.log("the return val is ready");
console.log(returnVal.value);
PostToServer(returnVal.value);
PostToServer(level,returnVal.value);
});
}
@ -24,7 +24,7 @@
}
}
function PostToServer(data) {
function PostToServer(level, data) {
var httpRequest = new XMLHttpRequest();//第一步:建立所需的对象
httpRequest.open("POST",""); //调用AddDataToServer
httpRequest.setRequestHeader("Content-Type", "application/json"); //设置请求头信息
@ -33,9 +33,7 @@
//alert('添加成功');
}
}
// console.log(typeof Array.from(data));
// console.log(Array.from(data));
httpRequest.send(JSON.stringify(Array.from(data))); //设置为发送给服务器数据
httpRequest.send(JSON.stringify(level+","+Array.from(data))); //设置为发送给服务器数据
}
</script>