Browse Source

clean example_a_flask

Bastien Sevajol 6 years ago
parent
commit
900182b045
1 changed files with 2 additions and 40 deletions
  1. 2 40
      example/example_a_flask.py

+ 2 - 40
example/example_a_flask.py View File

@@ -3,33 +3,11 @@ import json
3 3
 from http import HTTPStatus
4 4
 
5 5
 from flask import Flask
6
-import time
7
-import yaml
8
-from beaker.middleware import SessionMiddleware
9
-
10 6
 import hapic
11 7
 from example import HelloResponseSchema, HelloPathSchema, HelloJsonSchema, \
12 8
     ErrorResponseSchema, HelloQuerySchema
13 9
 from hapic.data import HapicData
14
-
15
-# hapic.global_exception_handler(UnAuthExc, StandardErrorSchema)
16
-# hapic.global_exception_handler(UnAuthExc2, StandardErrorSchema)
17
-# hapic.global_exception_handler(UnAuthExc3, StandardErrorSchema)
18
-# bottle.default_app.push(app)
19
-
20
-# session_opts = {
21
-#     'session.type': 'file',
22
-#     'session.data_dir': '/tmp',
23
-#     'session.cookie_expires': 3600,
24
-#     'session.auto': True
25
-# }
26
-# session_middleware = SessionMiddleware(
27
-#     app,
28
-#     session_opts,
29
-#     environ_key='beaker.session',
30
-#     key='beaker.session.id',
31
-# )
32
-# app = session_middleware.wrap_app
10
+from hapic.ext.flask import FlaskContext
33 11
 
34 12
 
35 13
 def bob(f):
@@ -105,25 +83,9 @@ class Controllers(object):
105 83
                          self.hello2, methods=['POST', ])
106 84
         app.add_url_rule('/hello3/<name>', "hello3", self.hello3)
107 85
 
108
-#app = bottle.Bottle()
109
-
110
-
111 86
 controllers = Controllers()
112 87
 controllers.bind(app)
113 88
 
114
-
115
-# time.sleep(1)
116
-# s = hapic.generate_doc(app)
117
-# ss = json.loads(json.dumps(s))
118
-# for path in ss['paths']:
119
-#     for method in ss['paths'][path]:
120
-#         for response_code in ss['paths'][path][method]['responses']:
121
-#             ss['paths'][path][method]['responses'][int(response_code)] = ss['paths'][path][method]['responses'][response_code]
122
-#             del ss['paths'][path][method]['responses'][int(response_code)]
123
-# print(yaml.dump(ss, default_flow_style=False))
124
-# time.sleep(1)
125
-
126
-hapic.set_context(hapic.ext.flask.FlaskContext(app))
89
+hapic.set_context(FlaskContext(app))
127 90
 print(json.dumps(hapic.generate_doc()))
128
-#import pdb; pdb.set_trace()
129 91
 app.run(host='localhost', port=8080, debug=True)