Add aiohttp, influx, logging boilerplate

This commit is contained in:
Tanner Collin 2021-12-24 08:00:12 +00:00
parent f9663b3f10
commit 3871ce6918

29
main.py Normal file
View File

@ -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)