Skip to content

Commit

Permalink
feat: create a server for cloud run
Browse files Browse the repository at this point in the history
i thought buildpack did this but nope...
  • Loading branch information
steveoh committed Feb 22, 2023
1 parent 9a4f307 commit 0e1469a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"gcloud",
"googleapis",
"gserviceaccount",
"Gunicorn",
"imdecode",
"imencode",
"IMREAD",
Expand Down
10 changes: 6 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
opencv-python==4.7.*
pdf2image==1.16.*
pandas==1.5.*
google-cloud-storage==2.7.*
google-cloud-logging==3.5.*
pdf2image==1.16.*
fastparquet==2023.1.0
flask==2.2.*
google-cloud-documentai==2.12.*
google-cloud-logging==3.5.*
google-cloud-storage==2.7.*
gunicorn==20.1.*
pyarrow==11.*
fastparquet==2023.1.0
40 changes: 40 additions & 0 deletions row_run_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python
# * coding: utf8 *
"""
server.py
a module that can receive web requests. this will be google cloud pub sub and
possibly github web hooks
"""

import logging
from os import getenv
from sys import stdout

from flask import Flask

import row_run

PORT = int(str(getenv("PORT"))) if getenv("PORT") else 8080
app = Flask(__name__)

logging.basicConfig(stream=stdout, level=logging.DEBUG)


@app.route("/", methods=["POST"])
def schedule():
"""schedule: the route that gcp cloud scheduler invokes"""
row_run.ocr_all_mosaics()

return ("", 204)


def start():
"""start: start the server for cloud run"""

# This is used when running locally. Gunicorn is used to run the
# application on Cloud Run. See entrypoint in Dockerfile.
app.run(host="127.0.0.1", port=PORT, debug=False)


if __name__ == "__main__":
start()

0 comments on commit 0e1469a

Please sign in to comment.