the1024.club/main.py

32 lines
809 B
Python
Raw Permalink Normal View History

2020-05-04 03:38:21 +00:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
from sanic import Sanic, response
from databases import Database
2020-05-04 03:57:52 +00:00
app = Sanic('1k')
db = Database('sqlite:///1k.db')
2020-05-04 03:38:21 +00:00
2020-05-04 03:57:52 +00:00
@app.route('/', methods=['GET', 'HEAD'])
2020-05-04 03:38:21 +00:00
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,
2020-05-04 05:57:50 +00:00
pubkey TEXT NOT NULL UNIQUE,
kilo TEXT
2020-05-04 03:38:21 +00:00
)""")
if __name__ == "__main__":
asyncio.run(init())
app.run(host="127.0.0.1", port=42069)