File tree Expand file tree Collapse file tree 4 files changed +55
-2
lines changed Expand file tree Collapse file tree 4 files changed +55
-2
lines changed Original file line number Diff line number Diff line change
1
+ # Use python as base image
2
+ FROM python:3.6-stretch
3
+
4
+ # Use working directory /app/model
5
+ WORKDIR /app/model
6
+
7
+ # Copy and install required packages
8
+ COPY requirements.txt .
9
+ RUN pip install --trusted-host pypi.python.org -r requirements.txt
10
+
11
+ # Copy all the content of current directory to working directory
12
+ COPY . .
13
+
14
+ # Set env variables for Cloud Run
15
+ ENV PORT 5000
16
+ ENV HOST 0.0.0.0
17
+
18
+ EXPOSE 5000:5000
19
+
20
+ # Run flask app
21
+ CMD ["python" ,"app.py" ]
Original file line number Diff line number Diff line change
1
+ import json
2
+ from flask import Flask , request
3
+ from syndicai import PythonPredictor
4
+
5
+ app = Flask (__name__ )
6
+
7
+
8
+ @app .route ('/' )
9
+ def hello ():
10
+ """ Main page of the app. """
11
+ return "Hello World!"
12
+
13
+
14
+ @app .route ('/predict' )
15
+ def predict ():
16
+ """ Return JSON serializable output from the model """
17
+ payload = request .args
18
+ classifier = PythonPredictor ("" )
19
+ return classifier .predict (payload )
20
+
21
+
22
+ if __name__ == '__main__' :
23
+ app .run (host = '0.0.0.0' , port = 5000 )
Original file line number Diff line number Diff line change
1
+ version : ' 3'
2
+ services :
3
+
4
+ flask_classifier :
5
+ build : .
6
+ ports :
7
+ - 5000:5000
Original file line number Diff line number Diff line change 1
- torch
2
- torchvision
1
+ torch == 1.7.1
2
+ torchvision == 0.8.2
3
+ flask == 1.1.2
4
+ requests == 2.18.4
You can’t perform that action at this time.
0 commit comments