Skip to content

Commit 3ccec6b

Browse files
committed
update readme
1 parent fee0446 commit 3ccec6b

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,18 @@
55
A barebones HTTP/1.1 client for Mojo using only Mojo and external C calls.
66

77
Please check out the `src/test.mojo` for an example of how to use the client for now. I will add documentation later.
8+
9+
```mojo
10+
from floki.session import Session, TCPConnection
11+
12+
fn main() raises -> None:
13+
var client = Session()
14+
var response = client.post(
15+
"http://jsonplaceholder.typicode.com/todos",
16+
{"Content-Type": "application/json"},
17+
data={"key1": "value1", "key2": "value2"},
18+
)
19+
print("POST Response Status Code:", response.status_code)
20+
for pair in response.body.as_dict().items():
21+
print(pair.key, ":", pair.value)
22+
```

scripts/util.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import tomllib
2-
import argparse
32
import os
43
import subprocess
54
import shutil
65
import glob
7-
import logging
86
from typing import Any
97
from pathlib import Path
108

119
import yaml
1210
import typer
1311

14-
logger = logging.getLogger(__name__)
1512

1613
app = typer.Typer()
1714

@@ -43,7 +40,7 @@ def __enter__(self) -> Path:
4340
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
4441
if TEMP_DIR.exists():
4542
shutil.rmtree(TEMP_DIR)
46-
logger.info("Temporary build directory removed.")
43+
print("Temporary build directory removed.")
4744

4845

4946
def format_dependency(name: str, version: str) -> str:
@@ -81,7 +78,7 @@ def generate_recipe() -> None:
8178
}
8279

8380
# Populate package information
84-
package_name = PROJECT_CONFIG["package"]["name"].replace("-", "_")
81+
package_name = PROJECT_CONFIG["package"]["name"]
8582
recipe["package"]["name"] = package_name
8683
recipe["package"]["version"] = PROJECT_CONFIG["package"]["version"]
8784

@@ -113,8 +110,9 @@ def generate_recipe() -> None:
113110
@app.command()
114111
def publish(channel: str) -> None:
115112
"""Publishes the conda packages to the specified conda channel."""
116-
logger.info(f"Publishing packages to: {channel}")
117-
for file in glob.glob(f'{CONDA_BUILD_PATH}/**/*.conda'):
113+
print(f"Publishing packages to: {channel}, from {CONDA_BUILD_PATH}.")
114+
for file in glob.glob(f'{CONDA_BUILD_PATH}/*.conda'):
115+
print(f"Uploading {file} to {channel}...")
118116
try:
119117
subprocess.run(
120118
["pixi", "upload", f"https://prefix.dev/api/v1/upload/{channel}", file],
@@ -128,7 +126,7 @@ def publish(channel: str) -> None:
128126
def remove_temp_directory() -> None:
129127
"""Removes the temporary directory used for building the package."""
130128
if TEMP_DIR.exists():
131-
logger.info("Removing temp directory.")
129+
print("Removing temp directory.")
132130
shutil.rmtree(TEMP_DIR)
133131

134132

@@ -148,13 +146,13 @@ def run_tests(path: str | None = None) -> None:
148146
"""Executes the tests for the package."""
149147
TEST_DIR = Path("src/test")
150148

151-
logger.info("Building package and copying tests.")
149+
print("Building package and copying tests.")
152150
with TemporaryBuildDirectory() as temp_directory:
153151
shutil.copytree(TEST_DIR, temp_directory, dirs_exist_ok=True)
154152
target = temp_directory
155153
if path:
156154
target = target / path
157-
logger.info(f"Running tests at {target}...")
155+
print(f"Running tests at {target}...")
158156
subprocess.run(["mojo", "test", target], check=True)
159157

160158

@@ -163,17 +161,17 @@ def run_examples(path: str | None = None) -> None:
163161
"""Executes the examples for the package."""
164162
EXAMPLE_DIR = Path("examples")
165163
if not EXAMPLE_DIR.exists():
166-
logger.info(f"Path does not exist: {EXAMPLE_DIR}.")
164+
print(f"Path does not exist: {EXAMPLE_DIR}.")
167165
return
168166

169-
logger.info("Building package and copying examples.")
167+
print("Building package and copying examples.")
170168
with TemporaryBuildDirectory() as temp_directory:
171169
shutil.copytree(EXAMPLE_DIR, temp_directory, dirs_exist_ok=True)
172170
example_files = EXAMPLE_DIR.glob("*.mojo")
173171
if path:
174172
example_files = EXAMPLE_DIR.glob(path)
175173

176-
logger.info(f"Running examples in {example_files}...")
174+
print(f"Running examples in {example_files}...")
177175
for file in example_files:
178176
name, _ = file.name.split(".", 1)
179177
shutil.copyfile(file, temp_directory / file.name)
@@ -185,17 +183,17 @@ def run_examples(path: str | None = None) -> None:
185183
def run_benchmarks(path: str | None = None) -> None:
186184
BENCHMARK_DIR = Path("benchmarks")
187185
if not BENCHMARK_DIR.exists():
188-
logger.info(f"Path does not exist: {BENCHMARK_DIR}.")
186+
print(f"Path does not exist: {BENCHMARK_DIR}.")
189187
return
190188

191-
logger.info("Building package and copying benchmarks.")
189+
print("Building package and copying benchmarks.")
192190
with TemporaryBuildDirectory() as temp_directory:
193191
shutil.copytree(BENCHMARK_DIR, temp_directory, dirs_exist_ok=True)
194192
benchmark_files = BENCHMARK_DIR.glob("*.mojo")
195193
if path:
196194
benchmark_files = BENCHMARK_DIR.glob(path)
197195

198-
logger.info(f"Running benchmarks in {benchmark_files}...")
196+
print(f"Running benchmarks in {benchmark_files}...")
199197
for file in benchmark_files:
200198
name, _ = file.name.split(".", 1)
201199
shutil.copyfile(file, temp_directory / file.name)

src/test.mojo

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
from floki.session import Session, TCPConnection
2-
from floki.header import Headers, Header
3-
42

53
fn test_http_request(mut client: Session[TCPConnection]) raises -> None:
64
# var response = client.get(

0 commit comments

Comments
 (0)