From 648b6dd0db6fc06a20e624131b00054a513b8047 Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Wed, 21 Jun 2023 02:11:14 -0700 Subject: [PATCH] fixes --- .dockerignore | 2 ++ .gitignore | 2 ++ Makefile | 6 +++- Pipfile | 3 +- Pipfile.lock | 76 +++++++++++++++++++++++++++++++++++++++++++++++++-- api.py | 11 ++++++-- 6 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ee826c1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Pipfile +Pipfile.lock diff --git a/.gitignore b/.gitignore index 0d10825..809be9e 100644 --- a/.gitignore +++ b/.gitignore @@ -185,3 +185,5 @@ Icon Network Trash Folder Temporary Items .apdisk + +requirements.txt diff --git a/Makefile b/Makefile index dbf1799..ff0998b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ SHELL = /bin/bash .DEFAULT_GOAL := build -IMAGE_NAME = git.michaellisano.com/mcf/uptime-monitor:latest +IMAGE_NAME = git.michaellisano.com/mcf/status-proxy:latest build: pipenv requirements > requirements.txt @@ -8,3 +8,7 @@ build: push: docker push $(IMAGE_NAME) + +run: + pipenv run hypercorn api.py -b 0.0.0.0:8080 + diff --git a/Pipfile b/Pipfile index d89bef8..824b87a 100644 --- a/Pipfile +++ b/Pipfile @@ -6,8 +6,9 @@ name = "pypi" [packages] fastapi = "*" requests = "*" +hypercorn = "*" [dev-packages] [requires] -python_version = "3.11" +python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock index 848c20a..f64b687 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "935de063e9b72586a848ac720ab6b4c42149dc14be11350737874a4c34335bec" + "sha256": "ef68b6b3212aea6bcd73844378cf0f6f9aa6d480ea240b4da1efe46be89ffd07" }, "pipfile-spec": 6, "requires": { - "python_version": "3.11" + "python_version": "3.9" }, "sources": [ { @@ -113,6 +113,14 @@ "markers": "python_full_version >= '3.7.0'", "version": "==3.1.0" }, + "exceptiongroup": { + "hashes": [ + "sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e", + "sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785" + ], + "markers": "python_version < '3.11'", + "version": "==1.1.1" + }, "fastapi": { "hashes": [ "sha256:95d757511c596409930bd20673358d4a4d709004edb85c5d24d6ffc48fabcbf2", @@ -121,6 +129,46 @@ "index": "pypi", "version": "==0.97.0" }, + "h11": { + "hashes": [ + "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d", + "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761" + ], + "markers": "python_version >= '3.7'", + "version": "==0.14.0" + }, + "h2": { + "hashes": [ + "sha256:03a46bcf682256c95b5fd9e9a99c1323584c3eec6440d379b9903d709476bc6d", + "sha256:a83aca08fbe7aacb79fec788c9c0bac936343560ed9ec18b82a13a12c28d2abb" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==4.1.0" + }, + "hpack": { + "hashes": [ + "sha256:84a076fad3dc9a9f8063ccb8041ef100867b1878b25ef0ee63847a5d53818a6c", + "sha256:fc41de0c63e687ebffde81187a948221294896f6bdc0ae2312708df339430095" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==4.0.0" + }, + "hypercorn": { + "hashes": [ + "sha256:4a87a0b7bbe9dc75fab06dbe4b301b9b90416e9866c23a377df21a969d6ab8dd", + "sha256:7c491d5184f28ee960dcdc14ab45d14633ca79d72ddd13cf4fcb4cb854d679ab" + ], + "index": "pypi", + "version": "==0.14.3" + }, + "hyperframe": { + "hashes": [ + "sha256:0ec6bafd80d8ad2195c4f03aacba3a8265e57bc4cff261e802bf39970ed02a15", + "sha256:ae510046231dc8e9ecb1a6586f63d2347bf4c8905914aa84ba585ae85f28a914" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==6.0.1" + }, "idna": { "hashes": [ "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4", @@ -129,6 +177,14 @@ "markers": "python_version >= '3.5'", "version": "==3.4" }, + "priority": { + "hashes": [ + "sha256:6f8eefce5f3ad59baf2c080a664037bb4725cd0a790d53d59ab4059288faf6aa", + "sha256:c965d54f1b8d0d0b19479db3924c7c36cf672dbf2aec92d43fbdaf4492ba18c0" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==2.0.0" + }, "pydantic": { "hashes": [ "sha256:07293ab08e7b4d3c9d7de4949a0ea571f11e4557d19ea24dd3ae0c524c0c334d", @@ -195,6 +251,14 @@ "markers": "python_version >= '3.7'", "version": "==0.27.0" }, + "toml": { + "hashes": [ + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.10.2" + }, "typing-extensions": { "hashes": [ "sha256:88a4153d8505aabbb4e13aacb7c486c2b4a33ca3b3f807914a9b4c844c471c26", @@ -210,6 +274,14 @@ ], "markers": "python_version >= '3.7'", "version": "==2.0.3" + }, + "wsproto": { + "hashes": [ + "sha256:ad565f26ecb92588a3e43bc3d96164de84cd9902482b130d0ddbaa9664a85065", + "sha256:b9acddd652b585d75b20477888c56642fdade28bdfd3579aa24a4d2c037dd736" + ], + "markers": "python_full_version >= '3.7.0'", + "version": "==1.2.0" } }, "develop": {} diff --git a/api.py b/api.py index 14409c8..537c1f0 100644 --- a/api.py +++ b/api.py @@ -1,13 +1,18 @@ from fastapi import FastAPI -from requests import get, post +from requests import get app = FastAPI() @app.get("/up/http-get") async def req_status(url: str): - res = get(url) + up: bool + try: + res = get(url) + up = res.status_code > 0 and res.status_code < 400 + except: + up = False return { - "up": res.status_code > 0 and res.status_code < 400 + "up": up } # ADD LATER: WEBSOCKETS