implement read
Browse files- games/game_util.py → game_util.py +5 -1
- games/game_angrybird.py +0 -4
- games/game_snake.py +0 -4
- main.py +17 -8
games/game_util.py → game_util.py
RENAMED
|
@@ -5,7 +5,7 @@ import requests
|
|
| 5 |
from fastapi import HTTPException, status
|
| 6 |
|
| 7 |
|
| 8 |
-
def
|
| 9 |
code = os.getenv("hfs_code")
|
| 10 |
if code is None:
|
| 11 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
|
@@ -21,3 +21,7 @@ def util_process(game: str, passcode: str, command: str):
|
|
| 21 |
|
| 22 |
x = requests.post(url, json=myobj, headers=headers)
|
| 23 |
return json.loads(x.text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from fastapi import HTTPException, status
|
| 6 |
|
| 7 |
|
| 8 |
+
def read(game: str, passcode: str, command: str):
|
| 9 |
code = os.getenv("hfs_code")
|
| 10 |
if code is None:
|
| 11 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
|
|
|
| 21 |
|
| 22 |
x = requests.post(url, json=myobj, headers=headers)
|
| 23 |
return json.loads(x.text)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def delete(game: str, passcode: str, command: str):
|
| 27 |
+
raise HTTPException(status_code=status.HTTP_501_NOT_IMPLEMENTED)
|
games/game_angrybird.py
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
import game_util
|
| 2 |
-
|
| 3 |
-
def process(passcode: str, command: str):
|
| 4 |
-
return game_util.util_process("angrybird", passcode, command)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
games/game_snake.py
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
import game_util
|
| 2 |
-
|
| 3 |
-
def process(passcode: str, command: str):
|
| 4 |
-
return game_util.util_process("snake", passcode, command)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from fastapi import FastAPI, Body
|
| 2 |
-
import
|
| 3 |
-
import games.game_angrybird as game_angrybird
|
| 4 |
|
| 5 |
|
| 6 |
app = FastAPI()
|
|
@@ -11,11 +10,21 @@ def root():
|
|
| 11 |
return {"message": "hi!"}
|
| 12 |
|
| 13 |
|
| 14 |
-
@app.post("/games/snake")
|
| 15 |
-
def main_snake(passcode: str, command: str=Body(
|
| 16 |
-
return
|
| 17 |
|
| 18 |
|
| 19 |
-
@app.post("/games/
|
| 20 |
-
def
|
| 21 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI, Body
|
| 2 |
+
import game_util
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
app = FastAPI()
|
|
|
|
| 10 |
return {"message": "hi!"}
|
| 11 |
|
| 12 |
|
| 13 |
+
@app.post("/games/snake/nlp/r")
|
| 14 |
+
def main_snake(passcode: str=Body(), command: str=Body()):
|
| 15 |
+
return game_util.read("snake", passcode, command)
|
| 16 |
|
| 17 |
|
| 18 |
+
@app.post("/games/snake/nlp/d")
|
| 19 |
+
def main_snake(passcode: str=Body(), command: str=Body()):
|
| 20 |
+
return game_util.delete("angrybird", passcode, command)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
@app.post("/games/angrybird/nlp/r")
|
| 24 |
+
def main_angrybird(passcode: str=Body(), command: str=Body()):
|
| 25 |
+
return game_util.read("angrybird", passcode, command)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
@app.post("/games/angrybird/nlp/d")
|
| 29 |
+
def main_angrybird(passcode: str=Body(), command: str=Body()):
|
| 30 |
+
return game_util.delete("angrybird", passcode, command)
|