skeleton for sanic

This commit is contained in:
Ben Morrison
2020-05-03 23:38:21 -04:00
parent 2df0f16463
commit eb730d1b14
3 changed files with 63 additions and 0 deletions

30
main.py Normal file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
from sanic import Sanic, response
from databases import Database
app = Sanic("1k")
db = Database("sqlite:///1k.db")
@app.route("/")
async def welcome(request):
return response.text("Welcome to the1024.club")
async def init():
print("Connecting to DB ...")
await db.connect()
print("Creating table ...")
await db.execute("""CREATE TABLE IF NOT EXISTS the_goods (
id INTEGER PRIMARY KEY,
fingerprint TEXT NOT NULL UNIQUE,
block TEXT
)""")
if __name__ == "__main__":
asyncio.run(init())
app.run(host="127.0.0.1", port=42069)