Beispiel #1
0
from django.core.wsgi import get_wsgi_application

import os
from django.core.wsgi import get_wsgi_application
from whitenoise import WhiteNoise

from whitenoise import WhiteNoise

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'newsapi.settings')

application = get_wsgi_application()

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

application = WhiteNoise(application, root=os.path.join(BASE_DIR, '/static'))

# application = DjangoWhiteNoise(application)
Beispiel #2
0
"""
WSGI config for localcode project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from whitenoise import WhiteNoise

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "localcode.settings")

application = get_wsgi_application()
application = WhiteNoise(application, root="blog/static")
Beispiel #3
0
"""
WSGI config for simple_api project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""

import os

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'simple_api.settings')
os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')

from configurations.wsgi import get_wsgi_application
from whitenoise import WhiteNoise

application = get_wsgi_application()
application = WhiteNoise(application, root='../staticfiles')
Beispiel #4
0
"""
WSGI config for mainichi project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from whitenoise import WhiteNoise

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mainichi.settings')

application = get_wsgi_application()
application = WhiteNoise(application, root='/static')
Beispiel #5
0
import sqlite3
import plotly
from whitenoise import WhiteNoise
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from dash_utils import make_table, make_card, ticker_inputs, make_item
from reddit_data import get_reddit
from tweet_data import get_options_flow
from fin_report_data import get_financial_report 

#Connect to sqlite database
conn = sqlite3.connect('stocks.sqlite')
#instantiate dash app server using flask for easier hosting
server = Flask(__name__)
app = dash.Dash(__name__,server = server ,meta_tags=[{ "content": "width=device-width"}], external_stylesheets=[dbc.themes.BOOTSTRAP])
server.wsgi_app = WhiteNoise(server.wsgi_app, root='static/')
#used for dynamic callbacks
app.config.suppress_callback_exceptions = True
#get options flow from twitter
get_options_flow()
flow = pd.read_sql("select datetime, text from tweets order by datetime desc", conn)
#get reddit data
get_reddit()
top_post = pd.read_sql("select title, score, post from reddit order by score desc", conn)

#creating dash layout
layout1 = html.Div([
dbc.Row([dbc.Col([make_card("Twitter Order Flow", 'primary', make_table('table-sorting-filtering2', flow, '17px', 10))])
         ,dbc.Col([make_card("Wallstreet Bets Top Daily Posts", 'primary', make_table('table-sorting-filtering', top_post, '17px', 4))])
        ],
        no_gutters=True,)#end row
Beispiel #6
0
"""
WSGI config for Aygalls project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from whitenoise import WhiteNoise
from uppm import settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "uppm.settings")

application = get_wsgi_application()
application = WhiteNoise(application, root=settings.STATIC_ROOT)
Beispiel #7
0
"""
WSGI config for djorg project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""

import os
from whitenoise import WhiteNoise
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djorg.settings")

application = get_wsgi_application()
application = WhiteNoise(application, root='/path/to/static/files')
application.add_files('/path/to/more/static/files', prefix='more-files/')
Beispiel #8
0
import os

import falcon
from whitenoise import WhiteNoise

ROOT = os.path.dirname(os.path.abspath(__file__))

app = falcon.API()
app = WhiteNoise(app, root=os.path.join(ROOT, 'static'), prefix='static/')

Beispiel #9
0
"""
WSGI config for di project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from whitenoise import WhiteNoise

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "metalearn.settings")

application = get_wsgi_application()
application = WhiteNoise(application, root='metalearn/static/')
Beispiel #10
0
"""
WSGI config for mkkNorthenCapital project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from whitenoise import WhiteNoise

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mkkNorthenCapital.settings')

application = get_wsgi_application()
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
application = WhiteNoise(application, root=os.path.join(BASE_DIR, 'assets'))
Beispiel #11
0
"""
WSGI config for viz project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

from whitenoise import WhiteNoise

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'viz.settings')

application = get_wsgi_application()

application = WhiteNoise(application, root='viz/eventtia/static/eventtia')
application.add_files('viz/eventtia/static/eventtia', prefix='static/')
Beispiel #12
0
''' Pulls in the gunicorn application '''
from whitenoise import WhiteNoise
from app.start import app
from config import storage

application = WhiteNoise(app, root='storage/static')

for location, alias in storage.STATICFILES.items():
    application.add_files(location, prefix=alias)
Beispiel #13
0
def create_app():
    """Initialize core application."""
    app = Flask(__name__, instance_relative_config=False)

    ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
    # configuration with environmetnal variables
    ENV_DIR = os.path.join(ROOT_DIR, '.env')
    load_dotenv(ENV_DIR)

    app.config.update(
        FLASK_ADMIN_SWATCH='cerulean',
        SECRET_KEY=os.getenv('SECRET_KEY'),
        SQLALCHEMY_DATABASE_URI=os.getenv('DATABASE_URL'),
        SQLALCHEMY_TRACK_MODIFICATIONS=os.getenv(
            'SQLALCHEMY_TRACK_MODIFICATIONS'),
        SECURITY_PASSWORD_SALT=os.getenv('SECURITY_PASSWORD_SALT'),
        MAIL_DEFAULT_SENDER=os.getenv('MAIL_DEFAULT_SENDER'),
        MAIL_PORT=os.getenv('MAIL_PORT'),
        MAIL_SERVER=os.getenv('MAIL_SERVER'),
        MAIL_USE_SSL=os.getenv('MAIL_USE_SSL'),
        MAIL_USERNAME=os.getenv('MAIL_USERNAME'),
        MAIL_PASSWORD=os.getenv('MAIL_PASSWORD'),
        SECURITY_CHANGEABLE=True,
        SECURITY_TRACKABLE=True,
        SECURITY_REGISTERABLE=True,
        SECURITY_SEND_REGISTER_EMAIL=True,
    )

    # Initialize plugins
    db.init_app(app)
    mail.init_app(app)
    migrate.init_app(app, db)
    bootstrap.init_app(app)

    app.wsgi_app = WhiteNoise(app.wsgi_app)
    my_static_folders = ('strains/static/strains/', )
    for static in my_static_folders:
        app.wsgi_app.add_files(static)

    from chemovar.users.models import User, Role
    from chemovar.compounds.models import Compound
    from chemovar.terpenes.models import Terpene
    from chemovar.strains.models import Strain
    from chemovar.assays.models import Assay

    class MyAdminIndexView(AdminIndexView):
        def is_accessible(self):
            return current_user.has_role('Superuser') or current_user.has_role(
                'Admin')

    admin = Admin(name='chemovar', index_view=MyAdminIndexView())
    admin.init_app(app)
    admin.add_view(ModelView(User, db.session, category='Auth'))
    admin.add_view(ModelView(Role, db.session, category='Auth'))
    admin.add_view(ModelView(Assay, db.session, category='Site'))
    admin.add_view(ModelView(Strain, db.session, category='Site'))
    admin.add_view(ModelView(Compound, db.session, category='Site'))
    admin.add_view(ModelView(Terpene, db.session, category='Site'))

    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security.init_app(app, user_datastore, register_blueprint=True)

    with app.app_context():
        # Import models
        from chemovar.strains import routes as strain_routes
        from chemovar.terpenes import routes as terpene_routes
        from chemovar.compounds import routes as compound_routes
        # Register Blueprints
        app.register_blueprint(strain_routes.strain_bp)
        app.register_blueprint(terpene_routes.terpene_bp)
        app.register_blueprint(compound_routes.compound_bp)

    return app
Beispiel #14
0
import os

from django.core.wsgi import get_wsgi_application
from gunicorn.http.wsgi import Response
from functools import wraps

from whitenoise import WhiteNoise


def wrap_default_headers(func):
    @wraps(func)
    def default_headers(*args, **kwargs):
        # patch wsgi.Response.default_headers to remove the 'Server: ' header from all server responses
        return [header for header in func(*args, **kwargs) if not header.startswith("Server: ")]

    return default_headers


Response.default_headers = wrap_default_headers(Response.default_headers)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "conf.settings")

application = get_wsgi_application()
application = WhiteNoise(application)
Beispiel #15
0
    def __init__(
        self,
        *,
        debug=False,
        title=None,
        version=None,
        openapi=None,
        openapi_route="/schema.yml",
        static_dir="static",
        static_route="/static",
        templates_dir="templates",
        auto_escape=True,
        secret_key=DEFAULT_SECRET_KEY,
        enable_hsts=False,
        docs_route=None,
        cors=False,
        cors_params=DEFAULT_CORS_PARAMS,
    ):
        self.secret_key = secret_key
        self.title = title
        self.version = version
        self.openapi_version = openapi
        self.static_dir = Path(os.path.abspath(static_dir))
        self.static_route = static_route
        self.templates_dir = Path(os.path.abspath(templates_dir))
        self.built_in_templates_dir = Path(
            os.path.abspath(os.path.dirname(__file__) + "/templates")
        )
        self.routes = {}
        self.docs_theme = DEFAULT_API_THEME
        self.docs_route = docs_route
        self.schemas = {}
        self.session_cookie = DEFAULT_SESSION_COOKIE

        self.hsts_enabled = enable_hsts
        self.cors = cors
        self.cors_params = cors_params
        # Make the static/templates directory if they don't exist.
        for _dir in (self.static_dir, self.templates_dir):
            os.makedirs(_dir, exist_ok=True)

        self.whitenoise = WhiteNoise(
            application=self._default_wsgi_app, index_file=True
        )
        self.whitenoise.add_files(str(self.static_dir))

        self.whitenoise.add_files(
            (
                Path(apistar.__file__).parent / "themes" / self.docs_theme / "static"
            ).resolve()
        )

        self.apps = {}
        self.mount(self.static_route, self.whitenoise)

        self.formats = get_formats()

        # Cached requests session.
        self._session = None
        self.background = BackgroundQueue()

        if self.openapi_version:
            self.add_route(openapi_route, self.schema_response)

        if self.docs_route:
            self.add_route(self.docs_route, self.docs_response)

        self.default_endpoint = None
        self.app = self.dispatch
        self.add_middleware(GZipMiddleware)
        if debug:
            self.add_middleware(DebugMiddleware)

        if self.hsts_enabled:
            self.add_middleware(HTTPSRedirectMiddleware)
        self.lifespan_handler = LifespanHandler()

        if self.cors:
            self.add_middleware(CORSMiddleware, **self.cors_params)
        self.add_middleware(ExceptionMiddleware, debug=debug)

        # Jinja enviroment
        self.jinja_env = jinja2.Environment(
            loader=jinja2.FileSystemLoader(
                [str(self.templates_dir), str(self.built_in_templates_dir)],
                followlinks=True,
            ),
            autoescape=jinja2.select_autoescape(["html", "xml"] if auto_escape else []),
        )
        self.jinja_values_base = {"api": self}  # Give reference to self.
        self.requests = (
            self.session()
        )  #: A Requests session that is connected to the ASGI app.
Beispiel #16
0
import os

from flask import Flask, render_template
from whitenoise import WhiteNoise

app = Flask(__name__)
app.secret_key = '[keep it secret]'
static_dir = os.path.join(os.path.dirname(__file__), 'static')
app.wsgi_app = WhiteNoise(app.wsgi_app, root=static_dir, prefix='static/')


@app.route('/')
def index():
    return render_template('index.html')


if __name__ == '__main__':
    app.jinja_env.auto_reload = True
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    app.run(debug=True)
Beispiel #17
0
def serve(folder, port):
    application = WhiteNoise(application=None, root=folder,  allow_all_origins=True)
    app = Application(application, port)
    app.run()