You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-14Lines changed: 39 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,26 +39,51 @@ Nowadays, is not perfect and we have a looong roadmap, but we hope this library
39
39
pip install py-ms
40
40
```
41
41
42
-
## Structure
42
+
#Quickstart
43
43
44
-
### pyms/config
45
-
Module to read yaml or json configuration from a dictionary or a path.
44
+
You need to create 2 files: main.py and config.yml:
46
45
47
-
### pyms/flask/app
48
-
With the function `create_app` initialize the Flask app, register [blueprints](http://flask.pocoo.org/docs/0.12/blueprints/)
49
-
and initialize all libraries such as Swagger, database, trace system, custom logger format, etc.
46
+
main.py
47
+
```python
48
+
from flask import jsonify
50
49
51
-
### pyms/flask/services
52
-
Integrations and wrappers over common libs like request, swagger, connexion
50
+
from pyms.flask.app import Microservice
53
51
54
-
### pyms/flask/healthcheck
55
-
This view is usually used by Kubernetes, Eureka and other systems to check if our application is running.
52
+
ms = Microservice(path=__file__) # 1.1
53
+
app = ms.create_app() # 2.1
56
54
57
-
### pyms/logger
58
-
Print logger in JSON format to send to server like Elasticsearch. Inject span traces in logger.
59
55
60
-
### pyms/tracer
61
-
Create an injector `flask_opentracing.FlaskTracer` to use in our projects.
56
+
@app.route("/") # 3.1
57
+
defexample():
58
+
return jsonify({"main": "hello world"})
59
+
60
+
61
+
if__name__=='__main__':
62
+
app.run()
63
+
```
64
+
65
+
config.yml
66
+
```yaml
67
+
pyms: # 1.2
68
+
requests:
69
+
data: {}
70
+
ms: # 1.3
71
+
DEBUG: true
72
+
APP_NAME: business-glossary
73
+
APPLICATION_ROOT : ""
74
+
SECRET_KEY: "gjr39dkjn344_!67#"
75
+
```
76
+
77
+
### So what did that code do?
78
+
79
+
1. Create a instance of PyMS Microservice class (#1.1). This initialization inject the configuration defined in the
80
+
1.3 block and could be accessed through current_app.config. Then, initialize the service defined in the 1.2 block. See [Services](services.md) for more details.
Copy file name to clipboardExpand all lines: docs/quickstart.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,8 @@ ms: # 1.3
35
35
SECRET_KEY: "gjr39dkjn344_!67#"
36
36
```
37
37
38
-
So what did that code do?
38
+
## So what did that code do?
39
+
39
40
1. Create a instance of PyMS Microservice class (#1.1). This initialization inject the configuration defined in the
40
41
1.3 block and could be accessed through current_app.config. Then, initialize the service defined in the 1.2 block. See [Services](services.md) for more details.
0 commit comments