summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--__main__.py19
-rwxr-xr-xcreate_venv.sh3
-rw-r--r--datatemplates/__init__.py0
-rw-r--r--datatemplates/agent_id.py6
-rw-r--r--modules/__init__.py2
-rw-r--r--modules/daemon.py10
-rw-r--r--requirements.txt1
8 files changed, 34 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 3b33b61..3aeb0d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.idea/
sta.token
spacetraders-sdk/
modules/spacetraders
diff --git a/__main__.py b/__main__.py
index 46d2815..16b0f63 100644
--- a/__main__.py
+++ b/__main__.py
@@ -1,10 +1,19 @@
import os.path
+from fastapi import FastAPI
+from .datatemplates.agent_id import AgentId
from .modules import daemon
from .config import Config
-if __name__ == "__main__":
- with open(os.path.join(os.path.dirname(__file__), Config.TOKEN_FILE_NAME)) as f:
- token = f.read().strip()
+app = FastAPI()
- d = daemon.Daemon(Config.AGENT_SYMBOL, token)
- d.run()
+
+@app.post("/tasks")
+async def get_tasks(agent_id: AgentId):
+ return "foo"
+
+# if __name__ == "__main__":
+# with open(os.path.join(os.path.dirname(__file__), Config.TOKEN_FILE_NAME)) as f:
+# token = f.read().strip()
+#
+# d = daemon.Daemon(Config.AGENT_SYMBOL, token)
+# d.run()
diff --git a/create_venv.sh b/create_venv.sh
index 5432f47..c5de596 100755
--- a/create_venv.sh
+++ b/create_venv.sh
@@ -18,6 +18,7 @@ for dir in $SCRIPT_ROOT/venv/lib/*; do
done
source venv/bin/activate
-cd $SDK_DIR_NAME
+pip install -r requirements.txt
+cd $SDK_DIR_NAME
pip install -r requirements.txt
diff --git a/datatemplates/__init__.py b/datatemplates/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/datatemplates/__init__.py
diff --git a/datatemplates/agent_id.py b/datatemplates/agent_id.py
new file mode 100644
index 0000000..2424a40
--- /dev/null
+++ b/datatemplates/agent_id.py
@@ -0,0 +1,6 @@
+from pydantic import BaseModel
+
+
+class AgentId(BaseModel):
+ callsign: str
+ token: str
diff --git a/modules/__init__.py b/modules/__init__.py
index e69de29..d593ada 100644
--- a/modules/__init__.py
+++ b/modules/__init__.py
@@ -0,0 +1,2 @@
+from fastapi import FastAPI
+app = FastAPI() \ No newline at end of file
diff --git a/modules/daemon.py b/modules/daemon.py
index a78e70b..085a7f6 100644
--- a/modules/daemon.py
+++ b/modules/daemon.py
@@ -1,10 +1,12 @@
import openapi_client
+from fastapi import FastAPI
from pprint import pprint
-class Daemon():
+fast_api = FastAPI()
+class Daemon:
def __init__(self, agent_symbol, token):
- config = openapi_client.Configuration(access_token = token)
+ config = openapi_client.Configuration(access_token=token)
self.api_client = openapi_client.ApiClient(config)
self.agents_api = openapi_client.AgentsApi(self.api_client)
@@ -13,6 +15,10 @@ class Daemon():
self.agent_symbol = agent_symbol
+ @fast_api.get("/")
+ def foo(self):
+ return "hello"
+
def run(self):
try:
api_response = self.agents_api.get_agent(self.agent_symbol)
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..13712cc
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
+fastapi[standard]