modified snakaAPI
This commit is contained in:
parent
f76b284d2c
commit
2a81b1e115
2 changed files with 5 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ dockerfile = "Dockerfile"
|
||||||
AWS_SECRET_ACCESS_KEY="tsec_6Bz1aMbfYQftuq5WfIVEDZkHwskU4MMjVywdtxSP6uxetEBvkSC2VHI9HfTeDgHr4D6kiz"
|
AWS_SECRET_ACCESS_KEY="tsec_6Bz1aMbfYQftuq5WfIVEDZkHwskU4MMjVywdtxSP6uxetEBvkSC2VHI9HfTeDgHr4D6kiz"
|
||||||
AWS_ENDPOINT_URL_S3="https://fly.storage.tigris.dev"
|
AWS_ENDPOINT_URL_S3="https://fly.storage.tigris.dev"
|
||||||
AWS_REGION="auto"
|
AWS_REGION="auto"
|
||||||
IMAGE_REF = "registry.fly.io/snakeapi-template:latest"
|
IMAGE_REF="registry.fly.io/snake-api-template:latest"
|
||||||
FLY_API_BASE_URL = "https://api.machines.dev/v1"
|
FLY_API_BASE_URL = "https://api.machines.dev/v1"
|
||||||
|
|
||||||
[http_service]
|
[http_service]
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,14 @@ import importlib.util
|
||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
|
||||||
# load handlers from converted notebook
|
|
||||||
notebook_path = os.environ.get("NOTEBOOK_PATH")
|
notebook_path = os.environ.get("NOTEBOOK_PATH")
|
||||||
if not notebook_path or not os.path.isfile(notebook_path):
|
if not notebook_path or not os.path.isfile(notebook_path):
|
||||||
raise RuntimeError(f"Notebook module not found: {notebook_path}")
|
raise RuntimeError(f"Notebook module not found: {notebook_path}")
|
||||||
|
|
||||||
spec = importlib.util.spec_from_file_location("notebook_module", notebook_path)
|
spec = importlib.util.spec_from_file_location("notebook_module", notebook_path)
|
||||||
notebook_module = importlib.util.module_from_spec(spec)
|
notebook_module = importlib.util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(notebook_module)
|
spec.loader.exec_module(notebook_module)
|
||||||
|
|
||||||
handlers = {
|
handlers = {
|
||||||
"info": notebook_module.info,
|
"info": notebook_module.info,
|
||||||
"start": notebook_module.start,
|
"start": notebook_module.start,
|
||||||
|
|
@ -53,9 +54,10 @@ def run_server(handlers: typing.Dict):
|
||||||
def get_notebook_path():
|
def get_notebook_path():
|
||||||
return jsonify({"path": notebook_path})
|
return jsonify({"path": notebook_path})
|
||||||
|
|
||||||
host = "::"
|
host = "0.0.0.0"
|
||||||
port = int(os.environ.get("PORT", "3006"))
|
port = int(os.environ.get("PORT", "3006"))
|
||||||
logging.getLogger("werkzeug").setLevel(logging.ERROR)
|
logging.getLogger("werkzeug").setLevel(logging.ERROR)
|
||||||
|
|
||||||
app.run(host=host, port=port)
|
app.run(host=host, port=port)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue