app.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. app = Flask(__name__)
  12. CORS(app)
  13. app.config["GOOGLE_API_KEY"] = os.environ["GOOGLE_API_KEY"]
  14. app.config["SQLALCHEMY_DATABASE_URI"] = os.environ["DATABASE_URI"]
  15. app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
  16. app.register_blueprint(game, url_prefix="/game")
  17. db.init_app(app)
  18. db.create_all(app=app)
  19. @app.route("/")
  20. def version():
  21. """
  22. Return the version of the API and a status message, "healthy"
  23. """
  24. return jsonify({"version": "1", "status": "healthy"})
  25. @app.route("/googleApiKey")
  26. def google_api_key():
  27. """
  28. Return the google API key configured for the application
  29. """
  30. return jsonify({"googleApiKey": app.config["GOOGLE_API_KEY"]})
  31. if __name__ == "__main__":
  32. app.run("0.0.0.0", 5000, debug=True)