Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

honor port env variable for python web server examples #338

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/active-jobs-dashboard/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from bottle import route, run, template, request
from string import capwords
import ibm_db_dbi as dbi
import os

conn = None
@route('/', method=('GET', 'POST'))
Expand Down Expand Up @@ -48,7 +49,7 @@ def static_assets(path):
with open(path[1:], "rb") as f:
return f.read()

run(host='0.0.0.0', port=3333, debug=True, reloader=True)
run(host='0.0.0.0', port=os.getenv('PORT', '3333'), debug=True, reloader=True)

# Example of running bottle with gunicorn:
# run(host='0.0.0.0', port=3333, debug=True, reloader=True, server='gunicorn', workers=4)
5 changes: 3 additions & 2 deletions python/bottle-example/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from bottle import request, get, post, static_file, route, run, template
import ibm_db_dbi as dbi
from itoolkit import *
from itoolkit.db2.idb2call import * #for local jobs
from itoolkit.db2.idb2call import * #for local jobs
import os

version = tuple(map(int, dbi.__version__.split('.')))
if version < (2, 0, 5, 5):
Expand Down Expand Up @@ -45,4 +46,4 @@ def cmd_toolkit():

return template('cmd', data=data)

run(host='0.0.0.0', port=9000, debug=True, reloader=True)
run(host='0.0.0.0', port=os.getenv('PORT', '9000'), debug=True, reloader=True)
2 changes: 2 additions & 0 deletions python/flask-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
env/
__pycache__/
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# -*- coding: utf-8 -*-

from flask import Flask, render_template, request
app = Flask(__name__)
import pyodbc
from itoolkit import *
from itoolkit.transport import DatabaseTransport #for local jobs
from itoolkit.transport import DatabaseTransport

app = Flask(__name__)#for local jobs

@app.route('/sample')
def sample():
Expand Down Expand Up @@ -43,4 +44,5 @@ def cmd_toolkit():
return render_template('cmd.html', data=data)

app.debug = True
app.run(host='0.0.0.0', port=9000,)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=int(os.getenv('PORT', 9000)),)
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from flask import Flask, render_template, request
app = Flask(__name__)
import ibm_db_dbi as dbi
from itoolkit import *
from itoolkit.db2.idb2call import * #for local jobs
from itoolkit.db2.idb2call import * #for local jobs
import os

app = Flask(__name__)

version = tuple(map(int, dbi.__version__.split('.')))
if version < (2, 0, 5, 5):
Expand Down Expand Up @@ -46,4 +47,5 @@ def cmd_toolkit():
return render_template('cmd.html', data=data)

app.debug = True
app.run(host='0.0.0.0', port=9000,)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=int(os.getenv('PORT', 9000)),)
10 changes: 9 additions & 1 deletion python/flask-example/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
flask
click==8.1.3
Flask==2.2.2
importlib-metadata==4.12.0
itoolkit==1.7.1
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
Werkzeug==2.2.2
zipp==3.8.1