from bootstrap import app app.run(host='0.0.0.0', port=20001)
from bootstrap import app from settings import get_flask_settings app.ENV = 'dev' if __name__ == '__main__': flask_settings = get_flask_settings(app.ENV) app.config['allowed_file_exts'] = flask_settings.allowed_file_exts app.secret_key = flask_settings.secret_key app.run(host=flask_settings.host, port=flask_settings.port, debug=flask_settings.debug)
app.register_blueprint(views.user_bp) app.register_blueprint(views.shelter_bp) app.register_blueprint(views.shelters_bp) app.register_blueprint(views.admin_bp) # API v0.1 app.register_blueprint(views.api.blueprint_user) app.register_blueprint(views.api.blueprint_shelter) app.register_blueprint(views.api.blueprint_shelter_picture) app.register_blueprint(views.api.blueprint_section) app.register_blueprint(views.api.blueprint_category) app.register_blueprint(views.api.blueprint_attribute) app.register_blueprint(views.api.blueprint_attribute_picture) app.register_blueprint(views.api.blueprint_value) app.register_blueprint(views.api.blueprint_property) app.register_blueprint(views.api.blueprint_page) app.register_blueprint(views.api.blueprint_translation) # API v0.1.1 app.register_blueprint(views.api.api_bp) # API v0.2 app.register_blueprint(views.api.apiv02_bp) if __name__ == "__main__": app.run(host=conf.WEBSERVER_HOST, port=conf.WEBSERVER_PORT, debug=conf.WEBSERVER_DEBUG)
from settings import settings from bootstrap import app application = app # alias for gunicorn if __name__ == '__main__': app.run(debug=settings.DEBUG)
Color: type: string responses: 200: description: A list of authors (may be filtered by identity) schema: $ref: '#/definitions/identity' examples: rgb: ['red', 'green', 'blue'] """ author = Identity.query.filter_by(firstname='Max').first() all_authors = { 'cmyk': [author.firstname, author.lastname], 'rgb': ['red', 'green', 'blue'] } if identity == 'all': result = all_authors else: result = {identity: all_authors.get(identity)} return jsonify(result) if __name__ == '__main__': manager = flask_restless.APIManager(app, flask_sqlalchemy_db=db) manager.create_api(Identity, url_prefix='/authors', methods=['GET', 'POST', 'DELETE']) app.run(debug=True, host='0.0.0.0', port=5000)
app.register_blueprint(views.api.blueprint_attribute_picture) app.register_blueprint(views.api.blueprint_value) app.register_blueprint(views.api.blueprint_property) app.register_blueprint(views.api.blueprint_page) app.register_blueprint(views.api.blueprint_translation) # API v0.2 app.register_blueprint(views.api.apiv02_bp) # Watch Templates files for change, In DEBUG MODE extra_files = [] if conf.WEBSERVER_DEBUG: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) extra_dirs = [ 'src/web/templates/', ] for extra_dir in extra_dirs: for dirname, dirs, files in os.walk(os.path.join(BASE_DIR, extra_dir)): for dir in dirs: extra_dirs.append(os.path.join(dirname, dir)) for filename in files: filename = os.path.join(dirname, filename) if os.path.isfile(filename): extra_files.append(filename) if __name__ == "__main__": app.run(host=conf.WEBSERVER_HOST, port=conf.WEBSERVER_PORT, debug=conf.WEBSERVER_DEBUG, extra_files=extra_files)
# Crear manager API Rest manager = restless.APIManager(app, flask_sqlalchemy_db=db) # Crear endpoints manager.create_api(Task, methods=['POST', 'GET', 'DELETE', 'PUT']) manager.create_api(User) manager.create_api(Comment, methods=['POST', 'GET', 'PUT']) manager.create_api(Category) manager.create_api(Status) manager.create_api(Priority) #Crear Admin admin = Admin(app, name="Task Manager", template_mode="bootstrap3") #Agregar Vistas del Admin admin.add_view(ModelView(Task, db.session)) admin.add_view(ModelView(User, db.session)) admin.add_view(ModelView(Comment, db.session)) admin.add_view(ModelView(Category, db.session)) admin.add_view(ModelView(Status, db.session)) admin.add_view(ModelView(Priority, db.session)) # Cors -> CORS(app) # Iniciar app if __name__ == "__main__": app.run(debug=True, host='0.0.0.0', port=80)
from models.users import User, UserInvitation from controllers import * from proxy import ReverseProxied from config import GEOTAGS_API_PREFIX, SECRET_KEY import filters __all__ = ['app', 'db', 'user_manager'] app.secret_key = SECRET_KEY user_adapter = SQLAlchemyAdapter(db, User, UserInvitationClass=UserInvitation) user_manager = UserManager(user_adapter, app) app.wsgi_app = ReverseProxied(app.wsgi_app) app.register_blueprint(auth.auth_api, url_prefix="%s/auth" % GEOTAGS_API_PREFIX) babel = Babel(app, default_locale='fr') # @app.route('/') # def index(): # if current_user.is_authenticated: # return render_template('main.html') # else: # form = user_manager.login_form() # return render_template('login.html', form=form) # Start development web server if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, debug=True)
app.register_blueprint(views.api.blueprint_attribute) app.register_blueprint(views.api.blueprint_attribute_picture) app.register_blueprint(views.api.blueprint_value) app.register_blueprint(views.api.blueprint_property) app.register_blueprint(views.api.blueprint_page) app.register_blueprint(views.api.blueprint_translation) # API v0.2 app.register_blueprint(views.api.apiv02_bp) # Watch Templates files for change, In DEBUG MODE extra_files = [] if conf.WEBSERVER_DEBUG: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) extra_dirs = ['src/web/templates/', ] for extra_dir in extra_dirs: for dirname, dirs, files in os.walk(os.path.join(BASE_DIR, extra_dir)): for dir in dirs: extra_dirs.append(os.path.join(dirname, dir)) for filename in files: filename = os.path.join(dirname, filename) if os.path.isfile(filename): extra_files.append(filename) if __name__ == "__main__": app.run(host=conf.WEBSERVER_HOST, port=conf.WEBSERVER_PORT, debug=conf.WEBSERVER_DEBUG, extra_files=extra_files)
from bootstrap import app import logging #yourapp/__init__.py #app = __name__, instance_relative_config=True # Load the default configuration #app.config.from_object('config.default') # Load the configuration from the instance folder #app.config.from_pyfile('config.py') # Load the file specified by the APP_CONFIG_FILE environment variable # Variables defined here will override those in the default configuration try: app.config.from_envvar('APP_CONFIG_FILE') app.config['HAS_CONFIG'] = True logging.warning( 'SUCCESSFUL: Config has been loaded from enviroment variables') app.run(host='0.0.0.0', port=int("20000")) except: logging.warning('Can\'t load conf from enviroment variables') finally: app.config.from_object('config.default') app.run(host='0.0.0.0', port=int("20000"))
markers = [(local.longitude, local.latitude) for local in locations] map = Map( identifier="user_map", lat=-3.1328552, lng=-59.9853138, zoom=5, style="height:900px;width:1900px;", markers=markers ) return render_template('maps/map.html', map = map) pass @app.errorhandler(InvalidUsage) def handle_invalid_usage(error): try: response = jsonify(error.to_dict()) response.status_code = error.status_code return response except Exception as exception: print exception if __name__ == '__main__': logging.basicConfig(filename=configuration['LOG_PATH'], level=logging.INFO, debug=True) db.create_all() try: app.run(host='0.0.0.0', port=configuration['APP_PORT'], debug=True) except Exception as exception: print exception
from bootstrap import app import logging #yourapp/__init__.py #app = __name__, instance_relative_config=True # Load the default configuration #app.config.from_object('config.default') # Load the configuration from the instance folder #app.config.from_pyfile('config.py') # Load the file specified by the APP_CONFIG_FILE environment variable # Variables defined here will override those in the default configuration try: app.config.from_envvar('APP_CONFIG_FILE') app.config['HAS_CONFIG'] = True logging.warning('SUCCESSFUL: Config has been loaded from enviroment variables') app.run(host='0.0.0.0', port=int("20000")) except: logging.warning('Can\'t load conf from enviroment variables') finally: app.config.from_object('config.default') app.run(host='0.0.0.0', port=int("20000"))
from models.users import User, UserInvitation from controllers import * from proxy import ReverseProxied from config import GEOTAGS_API_PREFIX, SECRET_KEY import filters __all__ = [ 'app', 'db', 'user_manager' ] app.secret_key = SECRET_KEY user_adapter = SQLAlchemyAdapter(db, User, UserInvitationClass=UserInvitation) user_manager = UserManager(user_adapter, app) app.wsgi_app = ReverseProxied(app.wsgi_app) app.register_blueprint(auth.auth_api, url_prefix="%s/auth" % GEOTAGS_API_PREFIX) babel = Babel(app, default_locale='fr') # @app.route('/') # def index(): # if current_user.is_authenticated: # return render_template('main.html') # else: # form = user_manager.login_form() # return render_template('login.html', form=form) # Start development web server if __name__== '__main__': app.run(host='0.0.0.0', port=5000, debug=True)
from resources.prototypes.todos import Todo, TodoList # from models.auth import User, Role @app.before_request def clientIp(): g.client_ip = request.remote_addr g.client_ua = User_Agent() ROOT = app.root_path class HelloWorld(Resource): def get(self): ip = request.remote_addr return jsonify(dict(version='1.0', abs_path=ROOT, your_ip=g.client_ip, user_agent=g.client_ua.__dict__, code=200)) ai.add_resource(HelloWorld, '/') ai.add_resource(TodoList, '/todos', endpoint='todos') ai.add_resource(Todo, '/todo/<int:todo_id>') if __name__ == '__main__': app.run(debug=True)
@app.route('/projects/<int:project_id>/cards/random') @app.route('/projects/<int:project_id>/cards/<int:card_id>') def card_get(project_id: int, card_id: int = None): card_format = str(request.args.get('format', default=CardFormat.HTML.name)).upper() if card_id: card = Card.query.filter_by(project_id=project_id, id=card_id).one() else: # select a random card num_cards = Card.query.filter_by(project_id=project_id).count() if not num_cards: return 'No cards exist for this project' card = Card.random(project_id) if card_format not in CardFormat.__members__: return f'Invalid format requested "{card_format}" must be one of: {CardFormat.__members__}' elif card_format.upper() == CardFormat.HTML.name: return render_template('cards/get.html', card=card) else: return f'Not yet implemented {card_format} != {CardFormat.HTML}' @app.route('/projects/<int:project_id>/items') def item_index(project_id: int): return str(Item.query.filter_by(project_id=project_id).all()) if __name__ == '__main__': app.run(debug=True)
from bootstrap import app, db import routes from DAO.main import Main as MainDAO teste = MainDAO() app.run()