modified dockerfile
This commit is contained in:
parent
a3f0d83304
commit
a4b19c9afa
8 changed files with 64 additions and 170 deletions
|
|
@ -4,7 +4,6 @@ WORKDIR /app
|
|||
RUN pip install --no-cache-dir jupyter flask awscli flask_cors nbconvert nbformat
|
||||
|
||||
COPY entrypoint.sh .
|
||||
COPY battlesnake_server.py .
|
||||
COPY notebook.ipynb .
|
||||
|
||||
RUN chmod +x entrypoint.sh
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
import os
|
||||
import logging
|
||||
import typing
|
||||
import json
|
||||
import nbformat
|
||||
from nbconvert import PythonExporter
|
||||
import subprocess
|
||||
from flask import Flask, request, jsonify
|
||||
from flask_cors import CORS
|
||||
|
||||
def run_server(handlers: typing.Dict):
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
|
||||
@app.get("/")
|
||||
def on_info():
|
||||
return handlers["info"]()
|
||||
|
||||
@app.post("/start")
|
||||
def on_start():
|
||||
handlers["start"](request.get_json())
|
||||
return "ok"
|
||||
|
||||
@app.post("/move")
|
||||
def on_move():
|
||||
return handlers["move"](request.get_json())
|
||||
|
||||
@app.post("/end")
|
||||
def on_end():
|
||||
handlers["end"](request.get_json())
|
||||
return "ok"
|
||||
|
||||
@app.get("/notebook")
|
||||
def get_notebook():
|
||||
with open("notebook.ipynb", "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
return content, 200, {"Content-Type": "application/json"}
|
||||
|
||||
@app.post("/notebook")
|
||||
def update_notebook():
|
||||
notebook_json = request.get_json()
|
||||
with open("notebook.ipynb", "w", encoding="utf-8") as f:
|
||||
json.dump(notebook_json, f)
|
||||
return {"status": "saved"}, 200
|
||||
|
||||
port = int(os.environ.get("PORT", "3006"))
|
||||
logging.getLogger("werkzeug").setLevel(logging.ERROR)
|
||||
app.run(host="0.0.0.0", port=port)
|
||||
Loading…
Add table
Add a link
Reference in a new issue