-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest-python-runtime.sh
More file actions
67 lines (57 loc) · 1.07 KB
/
test-python-runtime.sh
File metadata and controls
67 lines (57 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'Usage:'
echo 'test-python-runtime.sh "release"'
echo 'e.g.: test-python-runtime.sh 3.8.0'
exit 0
fi
echo
echo 'Creating test app for Python. Open URL in browser.'
echo
cd ~
mkdir -p pyapp; cd pyapp
# create runtime.txt
cat > runtime.txt <<EOF
export python-$1
EOF
echo [runtime.txt]
cat runtime.txt
echo
# create requirements.txt
cat > requirements.txt <<EOF
Flask==0.12.2
EOF
echo [requirements.txt]
cat requirements.txt
echo
# create manifest.yaml
cat > manifest.yml << EOF
---
applications:
- name: pyapp
host: pyapp
path: .
command: python server.py
EOF
echo [manifest.yml]
cat manifest.yml
echo
# create server.py
cat > server.py << EOF
import os
from flask import Flask
app = Flask(__name__)
port = int(os.environ.get('PORT', 3000))
@app.route('/')
def hello():
return "Hello World from Python $1"
if __name__ == '__main__':
app.run(port=port)
EOF
echo [server.py]
cat server.py
echo
# switch to development space, delete any existing pyapp, upload app
xs target -s development
xs delete -f pyapp
xs push