File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ _Note: you may need to install `pytest` using `pip install pytest`._
32
32
33
33
## Deploy
34
34
35
- ```
35
+ ``` sh
36
36
# Set an environment variable with your GCP Project ID
37
37
export GOOGLE_CLOUD_PROJECT=< PROJECT_ID>
38
38
Original file line number Diff line number Diff line change 17
17
import subprocess
18
18
import sys
19
19
20
+
20
21
app = Flask (__name__ )
21
22
23
+
22
24
# [START run_system_package_handler]
23
25
@app .route ('/diagram.png' , methods = ['GET' ])
24
26
def index ():
27
+ # Uses the graphviz DOT language
28
+ # https://www.graphviz.org/doc/info/lang.html
25
29
try :
26
30
image = create_diagram (request .args .get ('dot' ))
27
31
@@ -35,6 +39,7 @@ def index():
35
39
# Flush the stdout to avoid log buffering.
36
40
sys .stdout .flush ()
37
41
42
+ # If no graphviz definition or bad graphviz def, return 400
38
43
if 'syntax' in str (e ):
39
44
return f'Bad Request: { e } ' , 400
40
45
@@ -47,7 +52,8 @@ def create_diagram(dot):
47
52
if not dot :
48
53
raise Exception ('syntax: no graphviz definition provided' )
49
54
50
- dot_args = ['/usr/bin/dot' , # Command to run
55
+ dot_args = [ # usr/bin/dot is a system package in the container
56
+ '/usr/bin/dot' , # Command to run
51
57
'-Glabel=Made on Cloud Run' , # Args
52
58
'-Gfontsize=10' ,
53
59
'-Glabeljust=right' ,
You can’t perform that action at this time.
0 commit comments