Add aiohttp, influx, logging boilerplate

master
Tanner Collin 2 years ago
parent f9663b3f10
commit 3871ce6918
  1. 29
      main.py

@ -0,0 +1,29 @@
import os
import logging
logging.basicConfig(
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s: - %(message)s',
level=logging.DEBUG if os.environ.get('DEBUG') else logging.INFO)
logging.getLogger('aiohttp').setLevel(logging.DEBUG if os.environ.get('DEBUG') else logging.WARNING)
import asyncio
from aiohttp import web
from datetime import datetime, timedelta
import pytz
app = web.Application()
from influxdb import InfluxDBClient
client = InfluxDBClient('localhost', 8086, database='sensors1')
async def get_thermostat():
pass
async def index(request):
return web.Response(text='hello world', content_type='text/html')
if __name__ == '__main__':
app.router.add_get('/', index)
loop = asyncio.get_event_loop()
loop.create_task(get_thermostat())
web.run_app(app, port=6903)
Loading…
Cancel
Save