diff options
author | mjfernez <mjfernez@gmail.com> | 2021-06-07 19:47:59 -0400 |
---|---|---|
committer | mjfernez <mjfernez@gmail.com> | 2021-06-07 19:48:59 -0400 |
commit | a4ef784946330abc6aed8e03accdf7541881df0f (patch) | |
tree | f0f191554f09e92feedae1b06bbb013c801c2b25 | |
parent | e36167843d8b23c057d244d38a7f96b584db2912 (diff) | |
download | ezcms-a4ef784946330abc6aed8e03accdf7541881df0f.tar.gz |
wsgi compatibility
Moves the setup() function outside of main so the app is setup before a
wrapper runs it. Also fixes deployment tutorial in the README
-rw-r--r-- | README | 14 | ||||
-rw-r--r-- | server.py | 6 | ||||
-rw-r--r-- | siteconfig.py | 2 |
3 files changed, 11 insertions, 11 deletions
@@ -44,7 +44,7 @@ zip), change into the directory, then: `python server.py` -Your server will (by default) be hosted on http://localhost:8000 +Your server will (by default) be hosted on http://127.0.0.1:5000 ## Adding Pages @@ -165,14 +165,16 @@ You can disable it by deleting the code under `send_file_from_site` or You should NOT run this server as in the quick start, but instead deploy it in an appropriate container. Refer to https://flask.palletsprojects.com/en/2.0.x/deploying/ -for options, but an easy option I like is to use uswgi. On a Debian-like distro +for options, but an easy option I like is to use uwsgi since it's well +documented. -`sudo apt install uwsgi` `python -m venv env` -`uwsgi -s /tmp/yourapplication.sock --manage-script-name --mount /yourapplication=server:app` +`pip install uwsgi` +`doas -u www uwsgi -s /var/path/to/your-flask.sock --manage-script-name --mount /=server:app --virtualenv ./env` Then point your main http daemon (niginx, apache, httpd) to the socket you -made. See nginx as an example here, more in the same doc: +made. There are examples for a nginx configuration in the uWSGI and Flask docs: -https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html +- https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html +- https://flask.palletsprojects.com/en/2.0.x/deploying/uwsgi/ @@ -192,7 +192,7 @@ def setup(): app.config.update({'DOMAIN': siteconfig.DOMAIN}) app.config.update({'HOME_TITLE': siteconfig.HOME_TITLE}) - +# Need to come first to be compatible with wsgi +setup() if __name__ == '__main__': - setup() - app.run(host=siteconfig.HOST, port=siteconfig.PORT) + app.run() diff --git a/siteconfig.py b/siteconfig.py index 28c3cbd..8dbe006 100644 --- a/siteconfig.py +++ b/siteconfig.py @@ -4,8 +4,6 @@ class siteconfig: HOME_TITLE = "WELCOME" # "HELLO WORLD!" LINKS_FILE = ".links" # ".lnx" DESC_FILE = ".description" # ".desc`" - HOST = "127.0.0.1" # "192.168.1.1" "1.2.3.4" - PORT = 8000 # 8080, 8001, 8002 DEFAULT_MIMETYPE = "application/octet-stream" # "text/plain" MIMETYPES = {} |