Metadata-Version: 2.4
Name: nexom
Version: 0.1.1
Summary: Lightweight Python Web Framework (WSGI)
Author: Touri Aida
Project-URL: Homepage, https://github.com/yourname/nexom
Project-URL: Repository, https://github.com/yourname/nexom
Project-URL: Issues, https://github.com/yourname/nexom/issues
Keywords: wsgi,web,framework,router,template
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: AsyncIO
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: mypy>=1.8; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5.1; extra == "dev"


# NEXOM
Lightweight Python Web Framework (WSGI)

Nexom はシンプルなコードで構築できることを最優先にしつつ、必要なら低レベル API に降りられる “脱出口” を用意することで、高度な要件でも設計上詰まらないことを目指す。

```

## 特徴

- WSGI ベース（ブラックボックスなし）
- シンプルなルーティング（Path / Static）
- Request / Response 抽象
- Middleware 対応
- 軽量テンプレートエンジン
- 静的ファイル配信
- CLI によるサーバー雛形生成
- src 構成・assets 同梱対応

```

## インストール

    pip install nexom

```

## クイックスタート

### サーバープロジェクト生成
```
    python -m nexom build-server myapp --out ./myapp
```

### 生成される構成
```
    myapp/
    ├─ pages/
    │  ├─ default.py
    │  ├─ document.py
    │  └─ _templates.py
    ├─ templates/
    │  ├─ base.html
    │  ├─ default.html
    │  └─ document.html
    ├─ static/
    │  └─ dog.jpeg
    ├─ router.py
    ├─ wsgi.py
    ├─ config.py
    └─ gunicorn.conf.py
```

### 起動

    cd myapp
    gunicorn wsgi:app

```

## 基本的な使い方

### ルーティング定義（router.py）

```
    from nexom.web.path import Path, Static, Pathlib
    from pages import default, document

    routing = Pathlib(
        Path("", default.main, "Home"),
        Path("doc/", document.main, "Docs"),
        Static("static/", "./static", "StaticFiles"),
    )
```

### ページハンドラ
```
    from nexom.web.request import Request
    from nexom.web.response import Response

    def main(request: Request, args: dict):
        return Response("Hello Nexom")
```


## Request
```
    from nexom.web.request import Request

主な属性：

- request.method
- request.path
- request.headers
- request.cookie

body の取得：

    body = request.read_body()

```

## Response

### 通常レスポンス
```
    from nexom.web.response import Response
    return Response("Hello World")
```
### JSON レスポンス
```
    return {"status": "ok"}
```
### Redirect
```
    from nexom.web.response import Redirect
    return Redirect("/login")
```
### エラーレスポンス
```
    from nexom.web.response import ErrorResponse
    return ErrorResponse(404, "Not Found")

```

## Middleware

### Middleware 定義

    def logger(request, args, next_):
        print(request.method, request.path)
        return next_(request, args)

### 登録
```
    routing.add_middleware(logger)

```

## テンプレート
```
    from nexom.web.template import Templates

    templates = Templates("templates", "default")
    html = templates.default(title="Hello Nexom")

```

## ライセンス

MIT License
