diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a597d15 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +SERVER_DOMAIN = "nostr.hu" +RELAY = "ws://127.0.0.1:8080" +BLOSSOM = "http://127.0.0.1:3000" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 033df5f..318bb28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .venv __pycache__ +.env \ No newline at end of file diff --git a/README.md b/README.md index fd1abc1..88b7a58 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,10 @@ Nostr event kind `34128` is used for mapping from the file path (that comes afte Install ======= -`pip install -r requirements.txt` +``` +cp .env.example .env +pip install -r requirements.txt +``` Upload ====== diff --git a/blossom.py b/blossom.py index 28a16e7..6b2e722 100644 --- a/blossom.py +++ b/blossom.py @@ -20,6 +20,7 @@ async def store(sk, data, blossom_server, sha256, path): tags=[ ["t", "upload"], ["x", sha256], + ["size", len(data)], ["expiration", "1777777777"] ] ) diff --git a/hostr.py b/hostr.py index 4aaf894..c31413a 100644 --- a/hostr.py +++ b/hostr.py @@ -1,13 +1,17 @@ +import os import sys import logging from aiohttp import web, ClientSession +from dotenv import load_dotenv from monstr.client.client import Client, ClientPool from monstr.encrypt import Keys -SERVER_DOMAIN = "nostr.hu" -RELAY = "ws://127.0.0.1:8080" -BLOSSOM = "http://127.0.0.1:3000" +load_dotenv() + +SERVER_DOMAIN = os.getenv('SERVER_DOMAIN') +RELAY = os.getenv('RELAY') +BLOSSOM = os.getenv('BLOSSOM') FILEMAP_KIND = "34128" logging.basicConfig(level=logging.INFO) @@ -68,4 +72,6 @@ async def serve_file(request): web.get("/", serve_file), web.get("/{path:.*}", serve_file) ]) -web.run_app(app, host='0.0.0.0', port=8000) + +if __name__ == "__main__": + web.run_app(app, host='0.0.0.0', port=8000) diff --git a/requirements.txt b/requirements.txt index bdf4927..8f5d84c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ aiohttp monstr +python-dotenv \ No newline at end of file diff --git a/uploadr.py b/uploadr.py index dca8a2d..8657d9c 100755 --- a/uploadr.py +++ b/uploadr.py @@ -7,13 +7,16 @@ import hashlib import time from datetime import datetime +from dotenv import load_dotenv from monstr.encrypt import Keys from monstr.client.client import Client from monstr.event.event import Event -RELAY = "wss://relay.magnifiq.tech" # Right now it's hardcoded -BLOSSOM = "https://blossom.nostr.hu" # Same here. +load_dotenv() + +RELAY = os.getenv('RELAY') +BLOSSOM = os.getenv('BLOSSOM') parser = argparse.ArgumentParser() parser.add_argument(