mirror of
https://github.com/the1024club/the1024.club.git
synced 2026-07-03 10:39:51 +00:00
skeleton for sanic
This commit is contained in:
30
main.py
Normal file
30
main.py
Normal 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)
|
||||
Reference in New Issue
Block a user