Beispiel #1
0
from back import db, create_app

app = create_app()
with app.app_context():
    db.create_all()
Beispiel #2
0
"""
Launch "algorithm" service server.
"""

from back import create_app
from flask import url_for

if __name__ == "__main__":
    app = create_app(run_algo=True)
    host = app.config.get("FLASK_HOST", "localhost")
    port = app.config.get("FLASK_PORT", 5010)
    servername = app.config["SERVER_NAME"]
    debug = app.config.get("DEBUG", True)
    print(f"Trying to launch Flask server on {host}:{port} with server_name {servername} (debug={debug})")

    mongo_host = app.config.get("MONGODB_HOST", None)
    mongo_port = app.config.get("MONGODB_PORT")
    mongo_db = app.config.get("MONGODB_DB")
    print(f"Using MongoDB URI: mongodb://{mongo_host}:{mongo_port}/{mongo_db}")


    # ---- Print routes ----
    # print("Routes")
    # for rule in app.url_map:
    #     url = url_for(rule.endpoint, **(rule.defaults or {}))
    #     print(url, rule.endpoint)

    print(f"Using Algo service URI: {app.config.get('ALGO_URI', None)}")
    app.run(host="0.0.0.0",port=5010, debug=True)
Beispiel #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os

from back import create_app, setting

app = create_app(os.getenv('FLASK_CONFIG', 'default'))

if __name__ == '__main__':
    host_ip = setting.HOST_IP
    app.run(host=host_ip)  # TODO:此处需要写进环境变量
Beispiel #4
0
import os
from dotenv import load_dotenv

dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
if os.path.exists(dotenv_path):
    load_dotenv(dotenv_path)

from back import create_app  # noqa

app = create_app('production')
Beispiel #5
0
#!/usr/bin/env python
# -*- coding: utf8 -*-

# Copyright 2016 Sébastien Maccagnoni
#
# This file is part of AwesomeShop.
#
# AwesomeShop is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# AwesomeShop is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with AwesomeShop. If not, see <http://www.gnu.org/licenses/>.
"""Create an app for WSGI"""

from back import create_app

app = create_app()
Beispiel #6
0
#
# AwesomeShop is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with AwesomeShop. If not, see <http://www.gnu.org/licenses/>.
"""Run AwesomeShop locally for development"""

from flask.helpers import send_from_directory
from werkzeug.exceptions import NotFound

from back import create_app

app = create_app(prefix='/api')
app.debug = True

@app.route('/')
@app.route('/<path:path>')
def static_file(path=None):
    if not path:
        path = 'index.html'
    try:
        return send_from_directory('webroot', path)
    except NotFound:
        return static_file()

app.run()