Skip to content

Commit 0c3971c

Browse files
committed
SlimeWeb: H2 Tls Testing
1 parent 5e3b115 commit 0c3971c

3 files changed

Lines changed: 91 additions & 0 deletions

File tree

frameworks/slimeweb-tls/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.13-slim
2+
3+
WORKDIR /app
4+
5+
RUN pip install --no-cache-dir uv slimeweb
6+
7+
RUN slime new arena
8+
9+
WORKDIR /app/arena
10+
11+
12+
COPY main.py /app/arena/main.py
13+
14+
EXPOSE 8443
15+
16+
CMD ["slime","run","main.py"]

frameworks/slimeweb-tls/main.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import json
2+
3+
from slimeweb import Slime, SlimeTls
4+
5+
app = Slime(__file__)
6+
7+
8+
def load_json_processing_file():
9+
with open("/data/dataset.json", "r") as file:
10+
return json.load(file)
11+
12+
13+
JSON_DATASET = load_json_processing_file()
14+
15+
16+
@app.route("/baseline2", method=["GET", "POST"])
17+
def baseline_test(req, resp):
18+
result = 0
19+
for q_val in req.query.values():
20+
try:
21+
result += int(q_val)
22+
except ValueError:
23+
pass
24+
if req.method == "POST":
25+
try:
26+
result += int(req.text)
27+
except ValueError:
28+
pass
29+
return resp.plain(str(result))
30+
31+
32+
@app.route("/json/{count}", method="GET")
33+
def json_test(req, resp):
34+
global JSON_DATASET
35+
count = int(req.params["count"])
36+
multiplier = int(req.query["m"])
37+
result = [
38+
{
39+
"id": data["id"],
40+
"name": data["name"],
41+
"category": data["category"],
42+
"price": data["price"],
43+
"quantity": data["quantity"],
44+
"active": data["active"],
45+
"tags": data["tags"],
46+
"rating": {
47+
"score": data["rating"]["score"],
48+
"count": data["rating"]["count"],
49+
},
50+
"total": data["price"] * data["quantity"] * multiplier,
51+
}
52+
for data in JSON_DATASET[:count]
53+
]
54+
55+
return resp.json({"items": result, "count": count})
56+
57+
58+
if __name__ == "__main__":
59+
app.serve(
60+
host="0.0.0.0",
61+
port=8443,
62+
static_path="/data/static",
63+
https=SlimeTls(cert="/certs/server.crt ", key="/certs/server.key"),
64+
)

frameworks/slimeweb-tls/meta.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"display_name": "SlimeWeb",
3+
"language": "Python",
4+
"type": "tuned",
5+
"engine": "hyper",
6+
"description": "SlimeWeb is a fast lightweight framework for python powered by rust",
7+
"repo": "https://github.com/ATOMMAX-2001/Slime/",
8+
"enabled": true,
9+
"tests": ["baseline-h2", "static-h2"],
10+
"maintainers": ["ATOMMAX-2001"]
11+
}

0 commit comments

Comments
 (0)