diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0647239 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2174b9d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Flask", + "type": "python", + "request": "launch", + "module": "flask", + "env": { + "FLASK_APP": "server.py", + "FLASK_ENV": "development" + }, + "args": [ + "run", + "--no-debugger" + ], + "jinja": true + } + ] +} \ No newline at end of file diff --git a/__pycache__/app.cpython-37.pyc b/__pycache__/app.cpython-37.pyc index 5f997c9..4257a9b 100644 Binary files a/__pycache__/app.cpython-37.pyc and b/__pycache__/app.cpython-37.pyc differ diff --git a/__pycache__/server.cpython-37.pyc b/__pycache__/server.cpython-37.pyc index 41192c9..aebb677 100644 Binary files a/__pycache__/server.cpython-37.pyc and b/__pycache__/server.cpython-37.pyc differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a3e7551 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,22 @@ +black==21.9b0 +click==8.0.3 +colorama==0.4.4 +colorlog==6.5.0 +colormap==1.0.4 +easydev==0.12.0 +Flask==2.0.2 +importlib-metadata==4.8.1 +itsdangerous==2.0.1 +Jinja2==3.0.2 +MarkupSafe==2.0.1 +mypy-extensions==0.4.3 +pathspec==0.9.0 +pexpect==4.8.0 +platformdirs==2.4.0 +ptyprocess==0.7.0 +regex==2021.10.23 +tomli==1.2.2 +typed-ast==1.4.3 +typing-extensions==3.10.0.2 +Werkzeug==2.0.2 +zipp==3.6.0 diff --git a/server.py b/server.py index be429ae..5a21d83 100644 --- a/server.py +++ b/server.py @@ -5,34 +5,22 @@ from colormap import rgb2hex app = Flask(__name__) -@app.route('/') +@app.route("/") def index(): - os.system('gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n cc2433') - return 'Index Page' + return "Index Page" -@app.route('/hello') + +@app.route("/colour") def hello(): - #a = rgb2hex(255, 255, 255) + # a = request.query_string + r = int(request.args.get("r")) + g = int(request.args.get("g")) + b = int(request.args.get("b")) + hex = rgb2hex(r, g, b) + hex = hex.replace("#", "") - #str = '56' + a + '00f0aa' - #os.system('gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n ${str}') - return request.query_string - -#adding variables -@app.route('/user/') -def show_user(username): - #returns the username - return 'Username: %s' % username - -@app.route('/post/') -def show_post(post_id): - #returns the post, the post_id should be an int - return str(post_id) - -@app.route('/user', methods=['GET','POST']) -def get_user(): - username = request.form['username'] - password = request.form['password'] - #login(arg,arg) is a function that tries to log in and returns true or false - status = login(username, password) - return status + str = "56" + hex + "00f0aa" + os.system( + f"gatttool -i hci0 -b b2:3b:03:00:14:d6 --char-write-req -a 0x0009 -n {str}" + ) + return request.query_string diff --git a/venv/pyvenv.cfg b/venv/pyvenv.cfg index f967d3d..1a1986d 100644 --- a/venv/pyvenv.cfg +++ b/venv/pyvenv.cfg @@ -1,3 +1,3 @@ -home = /usr/bin -include-system-site-packages = false -version = 3.7.3 +home = C:\Users\karl.hudgell\.pyenv\pyenv-win\versions\3.7.2 +include-system-site-packages = false +version = 3.7.2