source: src/mapservice/codegen/templates/__main__.mustache@ 041e464

debian/bullseye
Last change on this file since 041e464 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
Line 
1{{#supportPython2}}
2#!/usr/bin/env python
3{{/supportPython2}}
4{{^supportPython2}}
5#!/usr/bin/env python3
6{{/supportPython2}}
7
8import connexion
9from flask_cors import CORS
10from flask import render_template
11
12from {{packageName}} import encoder
13
14from {{packageName}}.server_impl.database.Model import db, User, ApiKey, db_test_setup
15
16app = connexion.App(__name__, specification_dir='./openapi/')
17application = app.app
18CORS(application)
19
20@application.before_first_request
21def create_database():
22 db_test_setup()
23
24@application.route("/mapservice/")
25def index():
26 return render_template('index.html')
27
28def 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
37if __name__ == '__main__':
38 main()
Note: See TracBrowser for help on using the repository browser.