Skip to content

Commit 50ba32a

Browse files
committed
add if __name to test file
1 parent 1c7ac08 commit 50ba32a

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

part2/reverse_flask_herd/Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: python reverse_flask.py
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from flask import Flask, render_template, request
2+
import os
23

34
app = Flask(__name__)
45

6+
app.config['DEBUG'] = False
7+
58

69
@app.route('/')
710
def get_string():
@@ -14,8 +17,4 @@ def reverse_string():
1417
return render_template(
1518
'result.html',
1619
result=str_to_reverse[::-1]
17-
)
18-
19-
if __name__ == '__main__':
20-
app.debug = True
21-
app.run()
20+
)

part2/reverse_flask_herd/run.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# run.py
2+
3+
import os
4+
from project.reverse_flask import app
5+
6+
host = '0.0.0.0'
7+
port = int(os.environ.get('PORT', 5000))
8+
9+
if app.config['DEBUG'] == True:
10+
app.run()
11+
else:
12+
app.run(host=host, port=port)
+10-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
__author__ = 'G'
1+
import unittest
2+
3+
from project.reverse_flask import app
4+
5+
class ConfigTest(unittest.TestCase):
6+
def test_not_in_debug(self):
7+
self.assertNotEqual(app.config['DEBUG'], True)
8+
9+
if __name__ == '__main__':
10+
unittest.main()

0 commit comments

Comments
 (0)