File tree Expand file tree Collapse file tree 6 files changed +60
-11
lines changed Expand file tree Collapse file tree 6 files changed +60
-11
lines changed Original file line number Diff line number Diff line change 1- from flask import Flask
2-
3- from system .routes import routes_blueprint
4-
5-
6- app = Flask (__name__ )
7- app .config .from_object ('system.config' )
8- app .register_blueprint (routes_blueprint )
Original file line number Diff line number Diff line change 1+ from flask import Flask
2+
3+ from system .db import db , migrate
4+ from system .blueprints import register_blueprints
5+ from system .commands import register_commands
6+
7+
8+ def create_app ():
9+ app = Flask (__name__ )
10+ app .url_map .strict_slashes = False
11+ app .config .from_object ('system.config' )
12+
13+ db .app = app
14+ db .init_app (app )
15+ migrate .init_app (app , db )
16+ register_blueprints (app )
17+ register_commands (app )
18+
19+ return app
Original file line number Diff line number Diff line change 1+ from system .routes import system_blueprint
2+
3+
4+ def register_blueprints (app ):
5+ with app .app_context ():
6+ app .register_blueprint (system_blueprint )
7+
8+ from telegram_bot .routes import telegram_blueprint
9+ app .register_blueprint (telegram_blueprint , url_prefix = '/telegram' )
Original file line number Diff line number Diff line change 1+ import click
2+
3+ from flask .cli import with_appcontext
4+
5+ import telegram_bot .polling
6+ import telegram_bot .webhook
7+
8+
9+ @click .command ('polling' )
10+ @with_appcontext
11+ def start_polling ():
12+ telegram_bot .polling .start_polling ()
13+
14+
15+ @click .command ('webhook' )
16+ @with_appcontext
17+ def start_webhook ():
18+ telegram_bot .webhook .set_webhook ()
19+
20+
21+ def register_commands (app ):
22+ app .cli .add_command (start_polling )
23+ app .cli .add_command (start_webhook )
Original file line number Diff line number Diff line change 1+ from flask_sqlalchemy import SQLAlchemy
2+ from flask_migrate import Migrate
3+
4+
5+ db = SQLAlchemy ()
6+ migrate = Migrate ()
Original file line number Diff line number Diff line change 1- from flask import Blueprint , current_app
1+ from flask import Blueprint
22
33
4- routes_blueprint = Blueprint ('system_routes' , __name__ )
4+ system_blueprint = Blueprint ('system_routes' , __name__ )
55
66
7- @routes_blueprint .route ('/' )
7+ @system_blueprint .route ('/' )
88def index ():
99 return 'It works'
You can’t perform that action at this time.
0 commit comments