예제 #1
0
from xml.etree import ElementTree

from apscheduler.schedulers.asyncio import AsyncIOScheduler
from gino.dialects.asyncpg import JSONB
from raven.contrib.sanic import Sentry
from sanic import Sanic
from sanic.response import file, html, json, redirect

from exchangerates.utils import Gino, cors, parse_database_url

HISTORIC_RATES_URL = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml'
LAST_90_DAYS_RATES_URL = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml'

app = Sanic()
app.config.update(
    parse_database_url(
        url=getenv('DATABASE_URL', 'postgresql://localhost/exchangerates')))

# Database
db = Gino(app)

# Sentry
sentry = Sentry(app)


class ExchangeRates(db.Model):
    __tablename__ = 'exchange_rates'

    date = db.Column(db.Date(), primary_key=True)
    rates = db.Column(JSONB())

    def __repr__(self):
예제 #2
0
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from gino.dialects.asyncpg import JSONB
from raven.contrib.sanic import Sentry
from sanic import Sanic
from sanic.response import file, html, json, redirect

from exchangerates.utils import Gino, cors, parse_database_url

HISTORIC_RATES_URL = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml"
LAST_90_DAYS_RATES_URL = (
    "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml")

app = Sanic()
app.config.update(
    parse_database_url(
        url=getenv("DATABASE_URL", "postgresql://localhost/exchangerates")))

# Database
db = Gino(app)

# Sentry
sentry = Sentry(app)


class ExchangeRates(db.Model):
    __tablename__ = "exchange_rates"

    date = db.Column(db.Date(), primary_key=True)
    rates = db.Column(JSONB())

    def __repr__(self):
예제 #3
0
from raven.contrib.sanic import Sentry
from exchangerates.utils import Gino, cors, parse_database_url, patch_request
from sanic import Sanic
from sanic.response import file, html, json, redirect


HISTORIC_RATES_URL = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml"
LAST_90_DAYS_RATES_URL = (
    "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml"
)


app = Sanic(name='xchangeapi')
app.config.update(
    parse_database_url(
        url=getenv("DATABASE_URL")
    )
)

# Database
#app.config.DB_USE_CONNECTION_FOR_REQUEST = False
db = Gino()
db.init_app(app)

# Sentry
sentry = Sentry(app)


class ExchangeRates(db.Model):
    __tablename__ = "exchange_rates"