Coder Social home page Coder Social logo

nsite's Introduction

Nostr Hosting Unit

It is a solution for having a static site (nsite) deployed under your npub. The raw data is stored on blossom servers, and the mapping from path to sha256 of the content is stored on relays.

Nostr Hosting Unit (this repo) acts as a frontend to your previously uploaded site (nsite). It fetches data from your relays and your blossom servers and presents it under <your_npub>.nostr.hu. It does not store anything, and stands on its own. Anyone can deploy the frontend under a different domain, thus making the hosting part redundant, too.

With this architecture it is possible to deploy a static site, or a simple application that doesn't use a backend.

Links in html pages work seamlessly using absolute paths to refer images or js and css files: <img src="/img/avatar.jpg">

By the end of the day it is a system that have redundant relays, redundant blossom servers and redundant frontends to ensure freedom of speech and censorship resistance.

Event spec

Nostr event kind 34128 is used for mapping from the file path (that comes after the domain in the http request) to the sha256 of the file content that is fetched by the frontend from the blossom servers.

{
    "kind": 34128,
    "tags": [
        ["d", "<path/to/file>"],
        ["sha256", "<hash_of_the_file_content>"]
    ],
    "content": "",
    "created_at": <mtime_of_file>,
    ...
}

Install

pip install -r requirements.txt

Upload

A script is provided in the repository to upload a directory which contains the files of the static msite:

python uploadr.py dir/to/msite

Server

python hostr.py

You will need a certificate for *.yourdomain.org, and also set up a wildcard domain in the DNS. You need to configure your webserver to handle wildcard domains and route its traffic to hostr.py.

nsite's People

Contributors

lez avatar

Stargazers

 avatar  avatar hzrd149 avatar  avatar  avatar  avatar calvadev⚡️ avatar

Watchers

 avatar

Forkers

trbouma

nsite's Issues

Subprocess exited with error on `pip install -r requirements.txt`

  • OS X, m1
  • Python 3.12.4 (using pyenv)
  • pip 24.1

pip install -r requirements.txt

...fails on secp256k1

Collecting pycryptodome>=3.20.0 (from monstr->-r requirements.txt (line 2))
  Using cached pycryptodome-3.20.0-cp35-abi3-macosx_10_9_universal2.whl.metadata (3.4 kB)
Collecting secp256k1>=0.14.0 (from monstr->-r requirements.txt (line 2))
  Using cached secp256k1-0.14.0.tar.gz (2.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      0.29.2
      Using bundled libsecp256k1
      running dist_info
      creating /private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1.egg-info
      writing /private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1.egg-info/PKG-INFO
      writing dependency_links to /private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1.egg-info/dependency_links.txt
      writing requirements to /private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1.egg-info/requires.txt
      writing top-level names to /private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1.egg-info/top_level.txt
      writing manifest file '/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1.egg-info/SOURCES.txt'
      reading manifest file '/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file '/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1.egg-info/SOURCES.txt'
      creating '/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-modern-metadata-3i12pwiq/secp256k1-0.14.0.dist-info'
      Traceback (most recent call last):
        File "/Users/RED/.pyenv/versions/3.12.4/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/RED/.pyenv/versions/3.12.4/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/RED/.pyenv/versions/3.12.4/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 368, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 497, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 265, in <module>
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 184, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
          dist.run_commands()
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 976, in run_command
          super().run_command(command)
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/command/dist_info.py", line 97, in run
          bdist_wheel = self.get_finalized_command('bdist_wheel')
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 302, in get_finalized_command
          cmd_obj = self.distribution.get_command_obj(command, create)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/hd/4yjqdk0x18jdcry20n_d33xc0000gn/T/pip-build-env-xcqtlrbb/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 862, in get_command_obj
          cmd_obj = self.command_obj[command] = klass(self)
                                                ^^^^^^^^^^^
      TypeError: 'NoneType' object is not callable
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.