def setup_databases(app=createApp()): with app.app_context(): db.drop_all() db.create_all() setup_users() setup_timeslots()
from application import createApp, db from flask_script import Manager from flask_migrate import Migrate, MigrateCommand import os app = createApp(os.getenv('FLASK_CONFIG') or 'default') manager = Manager(app) migrate = Migrate(app, db) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
from application import createApp from config import Config as cfg app = createApp(cfg) if __name__ == '__main__': app.run(port=cfg.PORT, host=cfg.HOST)
from application import createApp app = createApp() app.config['CORS_HEADERS'] = 'Content-Type' @app.route('/') def home(): return """ <head> <title>my-university</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> </head> <body> <div class="container"> <h3 class="text-center">My-University flask application</h3> <div class="d-flex justify-content-center mt-4"> <button class="btn btn-primary btn-lg mr-3"> <a class="text-white" id='chat_button'> Go to chat </a> </button> <button class="btn btn-primary btn-lg"> <a class="text-white" id='api_button'> Go to API </a> </button> </div> </div> </body> <script> let chat_address = window.location + '/chat'; let api_address = window.location + '/api'; document.getElementById("chat_button").setAttribute("href", chat_address); document.getElementById("api_button").setAttribute("href", api_address);