From f71ec9fe8c9d73907c58725686addd40e4f45a69 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 18 Oct 2023 15:22:57 +0800 Subject: [PATCH] [build & docs] update docs and build-system --- .gitignore | 4 ++++ README.md | 36 ++++++++++++------------------------ app.py | 6 +++--- pyproject.toml | 11 +++++++++++ requirements.txt | 1 + 5 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index 651df8a..2d87c3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ .virtualenv/* __pycache__ database.db +test +dist +build +neoDNS.egg-info diff --git a/README.md b/README.md index 0e3790d..ca6fe06 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,19 @@ # neoDNS -Lightweight "DNS" that operates by returning http page +Lightweight "DNS" that operates by using http requests -## Operation +### Development -user sends the auth data to server through https, like this: - -```json -{ - "operation": "get", - "name": "media server", - "password": "12345" -}, -{ - "operation": "set", - "name": "game server", - "password": "abcde", - "address": "8.8.8.8" -} +```bash +pip install -r requirements.txt +flask run ``` -server receives the message and respond to the message: -```json -{ - "1.1.1.1" -}, -{ - "OK" -} +### Deployment + +refer to the tutorial [here](https://flask.palletsprojects.com/en/2.3.x/tutorial/deploy/) + +```bash +pip install waitress +waitress-serve ``` diff --git a/app.py b/app.py index 8ebc2b6..3b3179b 100644 --- a/app.py +++ b/app.py @@ -92,9 +92,9 @@ def add_address(): @app.route("/set/") def set_ip(): - domain_id = request.args.get("domain_name") + domain_id = request.args.get("domain_id") password = request.args.get("password") - new_ip = request.args.get("ip") + new_ip = request.args.get("new_ip") new_pass = request.args.get("new_pass") if not (domain_id and password): @@ -108,7 +108,7 @@ def set_ip(): conn = sqlite3.connect("database.db") if new_ip: conn.execute( - "UPDATE domains SET ip = ? WHERE id = ?", new_ip) + "UPDATE domains SET ip = ? WHERE id = ?", (new_ip, domain_id)) if new_pass: conn.execute( "UPDATE domains SET password_hash = ? WHERE id = ?", diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7b5e660 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,11 @@ +[build-system] +requires = ["setuptools", "flask", "Werkzeug"] +build-backend = "setuptools.build_meta" + +[project] +name = "neoDNS" +version = "0.1" +dependencies = [ + "flask", + "Werkzeug" +] diff --git a/requirements.txt b/requirements.txt index 7e10602..f8f300f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ flask +Werkzeug