Skip to main content

Lightweight Python Web Framework (WSGI)

Project description

Nexom

Lightweight Python Web Framework (WSGI)

Nexomは短いコードで最低限動作し、シンプルで理解のしやすい設計・構造を目指しています。 また細かい仕様も変更でき、多様な処理に対応します。

主な機能セット

  • WSGIベースの軽量Webフレームワーク
  • ルーティング(GET/POST、動的パス引数)
  • 静的ファイル配信
  • Request/ResponseのシンプルAPI(HTML/JSON/Redirect/エラーページ)
  • テンプレート(ObjectHTML: extends/import/slot)
  • ビルドイン標準認証サーバー&クライアント(AuthService/AuthClient)
  • Cookie管理
  • ミドルウェア対応
  • プロジェクト生成(buildTools)
  • マルチパートアップロードと並列ストレージ基盤(ParallelStorage/MultiPartUploader)

はじめる

最初のサーバーを起動するには、3つの手順が必要です。

  1. プロジェクトディレクトリを作成
  2. nexomをpipでインストール、プロジェクトのビルド
  3. 起動

1.プロジェクトディレクトリの作成

準備

用意していない場合はディレクトリを作成し、仮想環境も準備してください

mkdir banana_project
cd banana_project

python -m venv venv
source venv/bin/activate

2. pipでインストール、サーバーのビルド

インストール

nexomをインストールします。

pip install

プロジェクトのビルド

プロジェクトディレクトリ上で、以下のコマンドを実行してください

もしNginxもしくはApacheを使用する場合 --gateway オプションにどちらか入力してください

$ python -m nexom start-project # --gateway nginx or apache

以下の構成でプロジェクトが生成されます。

banana_project/
├─ app/
│  ├─ pages/
│  │  ├─ __init__.py
│  │  ├─ _templates.py
│  │  └─ * pages *
│  ├─ static/
│  │  └─ * static items *
│  ├─ templates/
│  │  └─ * html files *
│  ├─ __init__.py
│  ├─ config.py
│  ├─ gunicorn.conf.py
│  ├─ router.py
│  └─ wsgi.py
├─ auth/
│  ├─ __init__.py
│  ├─ config.py
│  ├─ gunicorn.conf.py
│  └─ wsgi.py
└─ data/
   ├─ log/
   │  └─ * app logs *
   ├─ db/
   │  └─ * app db *
   └─ gateway/
      ├─ app.nginx.conf
      └─ app.apache.conf

3.起動

以下のコマンドを起動します。

$ python -m nexom run

ブラウザからアクセスできるようになります。 デフォルトのポートは8080です。

http://localhost:8080

ポートなどの設定は config.py から変更してください。

Nginx等使用して外部公開する

gatewayディレクトリにある設定を読み込んでください

http {
    include /home/ubuntu/banana_project/gateway/*.conf;
}

Systemdに登録して自動起動する

Ubuntuの場合

  1. /etc/systemd/system に、 banana_sample.service を作成します。
  2. banana_sample.service に以下を書き込みます。(これは一例です。環境に合わせて設定してください。)

サーバーのディレクトリが /home/ubuntu/banana_project にある場合

[Unit]
Description=Nexom Web Freamework
After=network.target

[Service]
User=www-data
Group=www-data
WorkingDirectory=/home/ubuntu/banana_project
Environment="PYTHONPATH=/home/ubuntu/banana_project"
ExecStart=/home/ubuntu/banana_project/venv/bin/gunicorn sample.wsgi:app --config sample/gunicorn.conf.py
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target

以下のコマンドを実行します

sudo systemd daemon-reload
sudo systemd enable banana_sample
sudo systemd start banana_sample

テンプレートユニットを活用して複数のアプリを効率的に管理

テンプレートユニットを活用し .service ファイルを一枚にまとめられます。

/etc/systemd/system/banana-project@.service

[Unit]
Description=Nexom Web Server (%i)
After=network.target

[Service]
User=www-data
Group=www-data
WorkingDirectory=/home/ubuntu/banana_project
Environment="PYTHONPATH=/home/ubuntu/banana_project"
ExecStart=/home/ubuntu/banana_project/venv/bin/gunicorn %iwsgi:app --config %i/gunicorn.conf.py
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
sudo systemd daemon-reload

sudo systemd enable banana-project@banana1
sudo systemd enable banana-project@banana2
sudo systemd enable banana-project@banana3

sudo systemd start banana-project@banana1
sudo systemd start banana-project@banana2
sudo systemd start banana-project@banana3

2026 1/28

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexom-1.1.41.tar.gz (83.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexom-1.1.41-py3-none-any.whl (96.2 kB view details)

Uploaded Python 3

File details

Details for the file nexom-1.1.41.tar.gz.

File metadata

  • Download URL: nexom-1.1.41.tar.gz
  • Upload date:
  • Size: 83.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nexom-1.1.41.tar.gz
Algorithm Hash digest
SHA256 de78d6c1b5f6695058ea6385982afc6526f17e3727e99d950f14c33dc23accb0
MD5 d89050d6e83ec441fb2c0cbf2b6487cc
BLAKE2b-256 43643a0362cf324fadadfdfa0b1e0738ec3bc0843fcbea75c0f207b355f6f2ca

See more details on using hashes here.

File details

Details for the file nexom-1.1.41-py3-none-any.whl.

File metadata

  • Download URL: nexom-1.1.41-py3-none-any.whl
  • Upload date:
  • Size: 96.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for nexom-1.1.41-py3-none-any.whl
Algorithm Hash digest
SHA256 dbcd7fbb0c15b356a0043650f1b59b556e7e6c0c2a19927d0baa1f952a8d114b
MD5 8ce396be4951b11c9e6996fccfa7eae7
BLAKE2b-256 814738edf6cdffe5a9cdef02cba76332e4e3fe3a1a7dc5c05f26f2fb2eb99559

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page