1
0
Fork
You've already forked nomadServe
0
a Nomadnet page server based on flask.
  • Python 100%
2025年12月30日 15:13:14 +01:00
.gitignore add a gitignore and use the default Reticulum config directory. 2025年12月29日 16:43:48 +01:00
__init__.py change the default announce interval. 2025年12月30日 15:13:14 +01:00
fileServer.py initial commit. 2025年12月29日 16:36:12 +01:00
LICENCE add a very valid licence, add support for announcing every 6hours and show the 'started' message only after the paths were registered. 2025年12月30日 12:29:53 +01:00
README.md fix alignment issues(again) in the readme's examples. 2025年12月29日 22:01:48 +01:00
session.py initial commit. 2025年12月29日 16:36:12 +01:00

nomadServe

NomadServe is a nomadnet page server that does not use CGI or fastCGI but instead aims to work more like flask. This means that this is not made for people who aren't developers but gives more power to people who are.

Examples

To run the examples, the example's python file should be in the same folder than the one containing the nomadServe folder.

Simple Routes

This example serves the index page and an about page.

from nomadServe import NomadServe
app = NomadServe("(nomadServe example) Simple Routes")
@app.route("/page/index.mu")
@app.route("/")
def index():
 return f"""#!c=0
>`cThis is the index page!`a
This is an example nomadServe server.
`[About nomadServe`:/about`]
"""
@app.route("/about")
def about():
 return "nomadServe is the coolest Nomadnet server!!"
app.start()

Session Store: Login

This example stores data in the session storage and implements a simple login page and an index page, telling the user if he is logged in or not.

from nomadServe import NomadServe
from nomadServe.session import SessionStorage
app = NomadServe("(nomadServe example) Session Store: Login")
session_storage = SessionStorage()
@app.route("/page/index.mu")
@app.route("/")
def index(link_id):
 session = session_storage.get(link_id)
 if session is None:
 return f"""#!c=0
>`c You are not logged in.
[Login Page`:/login`]
"""
 else:
 username = session["username"]
 return f"""#!c=0
>`c Welcome, {username}!
`aThis can only be seen when you're logged in!
`[Login Page`:/login`]
"""
@app.route("/login")
def login(data, link_id):
 if data is not None:
 username = data.get("field_username", None)
 if username is not None:
 session_storage.add(link_id, {"username": username})
 return f"#!c=0\nWelcome, {username}!\n`[Home`:/`]"
 else:
 return "#!c=0\nError"
 else:
 return "#!c=0\n`B444`<username`>`b `[Login`:/login`username]\n`[Home`:/`]"
app.start()

File Server

This example will serve all files in the 'files' directory on the server's /file/ path.

from nomadServe import NomadServe, fileServer
app = NomadServe("(nomadServe example) File Server")
fileServer.register(app, "files", "file")
@app.route("/page/index.mu")
@app.route("/")
def index(link_id):
 session = session_storage.get(link_id)
 if session is not None:
 username = session["username"]
 message = f"Welcome, {username}!"
 else:
 message = "You are not logged in"
 return f"""#!c=0
>`c{message}`aThis is an example nomadServe server.
`[Files`:/files`]
`[Login Page`:/login`]
"""
@app.route("/login")
def login(data, link_id):
 if data is not None:
 username = data.get("field_username", None)
 if username is not None:
 session_storage.add(link_id, {"username": username})
 return f"#!c=0\nWelcome, {username}!\n`[Home`:/`]"
 else:
 return "#!c=0\nError"
 else:
 return "#!c=0\n`B444`<username`>`b `[Login`:/login`username]\n`[Home`:/`]"
app.start()