app.py 912 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. """
  2. Main entry-point for the TerrAssumptions API server
  3. Running this file directly will launch a development server.
  4. The WSGI-compatible Flask server is exposed from this module as app.
  5. """
  6. import os
  7. from flask import Flask, jsonify
  8. from flask_cors import CORS
  9. from db import db
  10. from game_api import game
  11. from extra_api import extra
  12. app = Flask(__name__)
  13. CORS(app)
  14. app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DATABASE_URI", "sqlite:////tmp/terrassumptions.db")
  15. app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
  16. app.register_blueprint(game, url_prefix="/game")
  17. app.register_blueprint(extra, url_prefix="/")
  18. db.init_app(app)
  19. db.create_all(app=app)
  20. @app.route("/")
  21. def version():
  22. """
  23. Return the version of the API and a status message, "healthy"
  24. """
  25. return jsonify({"version": "5", "status": "healthy"})
  26. if __name__ == "__main__":
  27. app.run("0.0.0.0", 5000, debug=True)