full envs from query parameters
Browse files- fetch.py +22 -2
- pyproject.toml +1 -1
fetch.py
CHANGED
@@ -3,7 +3,7 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
|
3 |
from contextlib import asynccontextmanager
|
4 |
from datetime import datetime
|
5 |
from fastapi import FastAPI, Request
|
6 |
-
from fastapi.responses import
|
7 |
from typing import Any
|
8 |
|
9 |
import httpx
|
@@ -56,7 +56,27 @@ async def log_request(request: Request, call_next: Any):
|
|
56 |
|
57 |
@app.get("/")
|
58 |
def read_root(request: Request):
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
|
62 |
@app.get("/a", response_class=PrettyJSONResponse)
|
|
|
3 |
from contextlib import asynccontextmanager
|
4 |
from datetime import datetime
|
5 |
from fastapi import FastAPI, Request
|
6 |
+
from fastapi.responses import FileResponse, PlainTextResponse, Response
|
7 |
from typing import Any
|
8 |
|
9 |
import httpx
|
|
|
56 |
|
57 |
@app.get("/")
|
58 |
def read_root(request: Request):
|
59 |
+
query_params = dict(request.query_params)
|
60 |
+
py_ver = query_params.pop("python", "3.12")
|
61 |
+
if "Windows" in request.headers.get("user-agent"):
|
62 |
+
pup_url = "https://raw.githubusercontent.com/liquidcarbon/puppy/main/pup.ps1"
|
63 |
+
script = [f"& ([scriptblock]::Create((iwr -useb {pup_url}).Content)) {py_ver}"]
|
64 |
+
else:
|
65 |
+
pup_url = "https://raw.githubusercontent.com/liquidcarbon/puppy/main/pup.sh"
|
66 |
+
script = [f"curl -fsSL {pup_url} | bash -s {py_ver}"]
|
67 |
+
|
68 |
+
pixi_packages = query_params.pop("pixi", "")
|
69 |
+
if pixi_packages:
|
70 |
+
for pkg in pixi_packages.split(","):
|
71 |
+
script.append(f"pixi add {pkg}")
|
72 |
+
|
73 |
+
# remaining query params are venvs
|
74 |
+
for venv, uv_packages in query_params.items():
|
75 |
+
for pkg in uv_packages.split(","):
|
76 |
+
script.append(f"pup add {venv} {pkg}")
|
77 |
+
|
78 |
+
script.append("# script ends here\n")
|
79 |
+
return PlainTextResponse("\n".join(script))
|
80 |
|
81 |
|
82 |
@app.get("/a", response_class=PrettyJSONResponse)
|
pyproject.toml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
[project]
|
2 |
name = "fetch"
|
3 |
-
version = "0.
|
4 |
description = "Puppy Installer"
|
5 |
authors = [
|
6 |
{ name = "Alex Kislukhin" }
|
|
|
1 |
[project]
|
2 |
name = "fetch"
|
3 |
+
version = "0.3.0"
|
4 |
description = "Puppy Installer"
|
5 |
authors = [
|
6 |
{ name = "Alex Kislukhin" }
|