def run_as_socketio(app, args): """在socketio中运行""" from app.extensions import socketio socketio.init_app(app) socketio.run( app, host=args.bind, debug=args.debug, use_reloader=args.use_reloader, port=args.port, )
x = input("Setting donation name for user: "******"; proceed? ") if x != 'y': return "Aborting" name = input("Donation name: ") user.donation_thank_you = name db.session.commit() return("Done.") def set_creator(tower_id, email_addr): t1 = TowerDB.query.get(tower_id) u1 = User.query.filter_by(email=email_addr).first() if t1 is None: print("Tower doesn't exist.") elif u1 is None: print("User doesn't exist.") else: input(f"Tower name: {t1}. Proceed? (y/n):") if t1.creator is None: t1.created_by(u1) print(f"Success! {tower_id} owner is now {email_addr}") else: print(f"There is already a creator: {t1.creator}") db.session.commit() if __name__ == '__main__': socketio.run(app=app, host='0.0.0.0',port=8080)
from app import create_app app = create_app('DEBUGGING') if __name__ == '__main__': from app.extensions import socketio socketio.run(app, port=8125)
# -*- coding: utf-8 -*- """Create an application instance.""" from app.app import create_app from app.extensions import socketio app = create_app() if __name__ == '__main__': socketio.run(app, port=5000)
accessible in the Flask shell. """ return dict( database_repository=database_repository, dynamodb_client=dynamodb_client, file_repository=file_repository, PrivateChat=PrivateChat, GroupChat=GroupChat, Community=Community, CommunityTopic=CommunityTopic, CommunityMembership=CommunityMembership, Image=Image, ImageType=ImageType, Message=Message, MessageType=MessageType, Reaction=Reaction, Notification=Notification, NotificationType=NotificationType, Role=Role, RolePermission=RolePermission, RoleName=RoleName, User=User, Location=Location, Token=Token, TokenType=TokenType, ) if __name__ == "__main__": socketio.run(app, host="0.0.0.0")
from gevent import monkey monkey.patch_all() import psycogreen.gevent psycogreen.gevent.patch_psycopg() from flask.helpers import get_debug_flag from app.app import create_app from app.extensions import socketio from app.settings import DevConfig, ProdConfig CONFIG = DevConfig if get_debug_flag() else ProdConfig app = create_app(CONFIG) if __name__ == '__main__' and get_debug_flag(): socketio.run(app)
from app import create_app from app.extensions import db, socketio from flask_script import Manager from flask_migrate import Migrate, MigrateCommand from app.models import User app = create_app() manager = Manager(app) Migrate(app, db) manager.add_command('db', MigrateCommand) if __name__ == '__main__': socketio.run(app, host='0.0.0.0', port=7771, debug=True)