This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
язык_программирования_python [2025/01/01 13:25] val [Web приложение] |
язык_программирования_python [2025/03/16 11:44] (current) val [Web приложение] |
||
---|---|---|---|
Line 37: | Line 37: | ||
import os | import os | ||
import configparser | import configparser | ||
- | |||
- | CONST_VER = "ver1.1" | ||
app = Flask(__name__) | app = Flask(__name__) | ||
Line 54: | Line 52: | ||
config = configparser.ConfigParser() | config = configparser.ConfigParser() | ||
config.read('/etc/pywebd/pywebd.conf') | config.read('/etc/pywebd/pywebd.conf') | ||
- | pywebd_port = os.environ.get('PYWEBD_PORT',config['default']['Listen']) | + | # pywebd_port = os.environ.get('PYWEBD_PORT',config['default']['Listen']) |
- | pywebd_doc_root = os.environ.get('PYWEBD_DOC_ROOT',config['default']['DocumentRoot']) | + | # pywebd_doc_root = os.environ.get('PYWEBD_DOC_ROOT',config['default']['DocumentRoot']) |
+ | if 'PYWEBD_PORT' in os.environ: | ||
+ | pywebd_port = os.environ.get('PYWEBD_PORT') | ||
+ | else: | ||
+ | pywebd_port = config['default']['Listen'] | ||
+ | if 'PYWEBD_DOC_ROOT' in os.environ: | ||
+ | pywebd_doc_root = os.environ.get('PYWEBD_DOC_ROOT') | ||
+ | else: | ||
+ | pywebd_doc_root = config['default']['DocumentRoot'] | ||
app.run(host="0.0.0.0", port=pywebd_port, debug=True) | app.run(host="0.0.0.0", port=pywebd_port, debug=True) | ||
# app.run(ssl_context=('/etc/pywebd/pywebd.crt', '/etc/pywebd/pywebd.key'), debug=True, host='0.0.0.0', port=pywebd_port) | # app.run(ssl_context=('/etc/pywebd/pywebd.crt', '/etc/pywebd/pywebd.key'), debug=True, host='0.0.0.0', port=pywebd_port) | ||
+ | |||
</code><code> | </code><code> | ||
+ | # mkdir -p /etc/pywebd/ | ||
+ | |||
# cat /etc/pywebd/pywebd.conf | # cat /etc/pywebd/pywebd.conf | ||
</code><code> | </code><code> | ||
[default] | [default] | ||
DocumentRoot = /var/www/ | DocumentRoot = /var/www/ | ||
- | Listen = 8443 | + | Listen = 4080 |
+ | </code><code> | ||
+ | # #cp /root/wild.crt /etc/pywebd/pywebd.crt | ||
+ | # #cp /root/wild.key /etc/pywebd/pywebd.key | ||
</code> | </code> | ||
Line 71: | Line 84: | ||
(venv1) :~/pywebd$ #export PYWEBD_PORT=4443 | (venv1) :~/pywebd$ #export PYWEBD_PORT=4443 | ||
(venv1) :~/pywebd$ #export PYWEBD_DOC_ROOT=/var/www/html/ | (venv1) :~/pywebd$ #export PYWEBD_DOC_ROOT=/var/www/html/ | ||
+ | (venv1) :~/pywebd$ #PYWEBD_PORT=4443 PYWEBD_DOC_ROOT=/var/www/html/ python app.py | ||
(venv1) :~/pywebd$ python app.py | (venv1) :~/pywebd$ python app.py | ||
- | (venv1) :~/pywebd$ pip freeze > requirements.txt | + | (venv1) :~/pywebd$ pip freeze | tee requirements.txt |
</code> | </code> | ||