adri 2 месяцев назад
Сommit
5506946615
7 измененных файлов с 57 добавлено и 0 удалено
  1. 10 0
      .gitignore
  2. 1 0
      .python-version
  3. 6 0
      Dockerfile
  4. 0 0
      README.md
  5. 27 0
      app.py
  6. 6 0
      main.py
  7. 7 0
      pyproject.toml

+ 10 - 0
.gitignore

@@ -0,0 +1,10 @@
+# Python-generated files
+__pycache__/
+*.py[oc]
+build/
+dist/
+wheels/
+*.egg-info
+
+# Virtual environments
+.venv

+ 1 - 0
.python-version

@@ -0,0 +1 @@
+3.12

+ 6 - 0
Dockerfile

@@ -0,0 +1,6 @@
+FROM python:3.12-slim
+RUN pip install flask requests
+COPY . /app
+WORKDIR /app
+EXPOSE 9000
+CMD ["python", "app.py"]   


+ 27 - 0
app.py

@@ -0,0 +1,27 @@
+from flask import Flask, request, jsonify
+import requests
+import os
+
+app = Flask(__name__)
+
+
+@app.route("/osmand", methods=["GET"])
+def forward_get_as_post():
+    # Convert GET parameters to JSON
+    data = dict(request.args)
+
+    # Forward as POST request with JSON body
+    target_url = f"http://reitti:8888/api/v1/ingest/owntracks?token={os.getenv('REITTI_API_TOKEN', '')}"  # Replace with your target URL
+    response = requests.post(target_url, json=data)
+
+    return jsonify(
+        {
+            "status": "forwarded",
+            "data_sent": data,
+            "target_status": response.status_code,
+        }
+    )
+
+
+if __name__ == "__main__":
+    app.run(host="0.0.0.0", port=9000)

+ 6 - 0
main.py

@@ -0,0 +1,6 @@
+def main():
+    print("Hello from location-forwarder!")
+
+
+if __name__ == "__main__":
+    main()

+ 7 - 0
pyproject.toml

@@ -0,0 +1,7 @@
+[project]
+name = "location-forwarder"
+version = "0.1.0"
+description = "Add your description here"
+readme = "README.md"
+requires-python = ">=3.12"
+dependencies = []