Add aiohttp, influx, logging boilerplate
This commit is contained in:
parent
f9663b3f10
commit
3871ce6918
29
main.py
Normal file
29
main.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user