From 6e0b83523e8028c2c70415b4ada862997f94b669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Claudino?= Date: Tue, 5 Sep 2017 11:40:23 -0300 Subject: [PATCH 1/2] wsgi-only Excluded standalone version. Now it's used only for development purpose. --- payment-system/server.py | 6 +++--- payment-system/server_wsgi.py | 17 ----------------- 2 files changed, 3 insertions(+), 20 deletions(-) delete mode 100644 payment-system/server_wsgi.py diff --git a/payment-system/server.py b/payment-system/server.py index 63d6e3e..dfc7f9c 100644 --- a/payment-system/server.py +++ b/payment-system/server.py @@ -4,9 +4,7 @@ # === Script to launch server === """ -This script launches payment-system server from configurations -using configurations returned by server_config(). -Used to run as standalone app. +This script launches payment-system server """ @@ -14,3 +12,5 @@ app = create_app() +if __name__=='__main__': + app.run() \ No newline at end of file diff --git a/payment-system/server_wsgi.py b/payment-system/server_wsgi.py deleted file mode 100644 index 69f16c6..0000000 --- a/payment-system/server_wsgi.py +++ /dev/null @@ -1,17 +0,0 @@ -from base.connect_db import ConnectDB -from utils.application_factory import create_app - -# === Script to launch server === - -""" -This script launches payment-system server from configurations -using configurations returned by server_config(). -""" - - -ConnectDB.connect_database() - -app = create_app() - -if __name__=='__main__': - app.run() \ No newline at end of file From 1076164b68451825dc5a4930a8d07dae1142c735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Claudino?= Date: Tue, 5 Sep 2017 11:40:45 -0300 Subject: [PATCH 2/2] wsgi-only Updated README.md --- README.md | 67 +------------------------------------------------------ 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/README.md b/README.md index 9ff1e21..dcb1d3b 100644 --- a/README.md +++ b/README.md @@ -44,71 +44,6 @@ Go to [neo4j admin page](http://0.0.0.0:7474/browser/) and change default passwo For more information and next steps in neo4j configuration read [this documentation](https://neo4j.com/docs/operations-manual/current/installation/docker/) on neo4j page. -## Certificates (for standalone only) -System is made for SSL, so, this needs SSL certificates. You could use self-signed certificates for testing/development purposes. Certificates pair should be names cert.pem and key.pem, you could find information on how to generate these certificates on **Self-Signed Certificates* section of [this link ](https://blog.miguelgrinberg.com/post/running-your-flask-application-over-https). - -HTTPS will be used only when *server.py* **is the main file**, this is not the case when running using ``flask run``. - -On unix shell, it basically consists in running: - -```SHELL -openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365 -``` - -this will generate files **cert.pem** and **key.pem**, these should be placed in our **running directory**. - -## Configuration files (standalone only) -The system uses some configuration files (they should be put in root directory too), these files are: - -### db_credentials.json - -These file contains information to acces neo4j database, in case, username as **user**, **password**, running host as **url**, **protocol ** (prefer to keep bolt as it is not tested with others) and neo4j running **port** -```JSON -{ - "user": "neo4j", - "password": "neo4j", - "url": "localhost", - "protocol": "bolt", - "port": 7687 -} -``` -An important observation is: all fields are mandatory, since with neo4j default values. - -### server_config.json - -This file has three primary fields: - -* **run_config**: could be understood as a python dictionary with values to be passed for flask application run command. These can be seen in *run* function section of [flask application object documentatio](http://flask.pocoo.org/docs/0.12/api/#application-object). This will be used only when *server.py* **is the main file**, this is not the case when running using ``flask run``. - -* **secret_key**: Secret key used to sign and crypto auth token -* **expiration_time**: time to live for token - -```JSON -{ - "run_config" : { - "port": 8080, - "host": "0.0.0.0" - }, - - "secret_key": "907839b1-2803-4605-b560-032c7c9e4c34", - "expiration_time": 3600 -} -``` - -### Standalone Execution: - -Once environment is prepared next step is run the application, running the application as standalone server (for development purposes) is simple. In running directory (where configuration files and cloned/unziped repository is) just execute: - -```SHELL -python3 virtual-wallet-simulator/server.py -``` - -or to run as flask application - -``` -SHELL -FLASK_APP='virtual-wallet-simulator/server.py' flask run -``` ## Execution in a container To permit easy execution in containers and services like Heroku (the testing platfom), configuration files have to be changed to enviroment variables, they are: @@ -124,7 +59,7 @@ Other variables are used for database connection, in this method, only bolt prot with these, using gunicorn would be simple as: ```SHELL -web: gunicorn --pythonpath payment-system server_wsgi:app --worker-class gevent -b 0.0.0.0:$PORT +web: gunicorn --pythonpath payment-system server:app --worker-class gevent -b 0.0.0.0:$PORT ``` ## Tests and documentation: