debian/bullseye
|
Last change
on this file since 1e7f556 was 5e4cb73, checked in by Joachim Langenbach <joachim.langenbach@…>, 8 years ago |
|
Refactored mapservice
- mapservice is a connexion python webservice with openapi defined api
- mapservice-webclient is a angular app, consuming the openapi webservice mapservice
|
-
Property mode
set to
100644
|
|
File size:
929 bytes
|
| Rev | Line | |
|---|
| [3a89adb] | 1 | {{#supportPython2}}
|
|---|
| 2 | #!/usr/bin/env python
|
|---|
| 3 | {{/supportPython2}}
|
|---|
| 4 | {{^supportPython2}}
|
|---|
| 5 | #!/usr/bin/env python3
|
|---|
| 6 | {{/supportPython2}}
|
|---|
| 7 |
|
|---|
| 8 | import connexion
|
|---|
| 9 | from flask_cors import CORS
|
|---|
| 10 | from flask import render_template
|
|---|
| 11 |
|
|---|
| 12 | from {{packageName}} import encoder
|
|---|
| 13 |
|
|---|
| 14 | from {{packageName}}.server_impl.database.Model import db, User, ApiKey, db_test_setup
|
|---|
| 15 |
|
|---|
| 16 | app = connexion.App(__name__, specification_dir='./openapi/')
|
|---|
| 17 | application = app.app
|
|---|
| 18 | CORS(application)
|
|---|
| 19 |
|
|---|
| 20 | @application.before_first_request
|
|---|
| 21 | def create_database():
|
|---|
| 22 | db_test_setup()
|
|---|
| 23 |
|
|---|
| 24 | @application.route("/mapservice/")
|
|---|
| 25 | def index():
|
|---|
| 26 | return render_template('index.html')
|
|---|
| 27 |
|
|---|
| 28 | def main():
|
|---|
| 29 | application.json_encoder = encoder.JSONEncoder
|
|---|
| 30 | app.add_api('openapi.yaml', arguments={'title': '{{appName}}'}, validate_responses=True)
|
|---|
| 31 | application.config.from_object('{{packageName}}.server_impl.Config.DevelopmentConfig')
|
|---|
| 32 |
|
|---|
| 33 | db.init_app(application)
|
|---|
| 34 |
|
|---|
| 35 | app.run(port={{serverPort}})
|
|---|
| 36 |
|
|---|
| 37 | if __name__ == '__main__':
|
|---|
| 38 | main()
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.