skeleton for sanic
This commit is contained in:
parent
2df0f16463
commit
eb730d1b14
|
@ -0,0 +1,2 @@
|
||||||
|
.venv
|
||||||
|
*.db
|
|
@ -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)
|
|
@ -0,0 +1,31 @@
|
||||||
|
aiofiles==0.5.0
|
||||||
|
aiosqlite==0.12.0
|
||||||
|
astroid==2.4.0
|
||||||
|
autopep8==1.5.2
|
||||||
|
certifi==2020.4.5.1
|
||||||
|
chardet==3.0.4
|
||||||
|
databases==0.3.2
|
||||||
|
h11==0.8.1
|
||||||
|
h2==3.2.0
|
||||||
|
hpack==3.0.0
|
||||||
|
hstspreload==2020.4.28
|
||||||
|
httptools==0.1.1
|
||||||
|
httpx==0.9.3
|
||||||
|
hyperframe==5.2.0
|
||||||
|
idna==2.9
|
||||||
|
isort==4.3.21
|
||||||
|
lazy-object-proxy==1.4.3
|
||||||
|
mccabe==0.6.1
|
||||||
|
multidict==4.7.5
|
||||||
|
pycodestyle==2.5.0
|
||||||
|
pylint==2.5.0
|
||||||
|
rfc3986==1.4.0
|
||||||
|
sanic==19.12.2
|
||||||
|
six==1.14.0
|
||||||
|
sniffio==1.1.0
|
||||||
|
SQLAlchemy==1.3.16
|
||||||
|
toml==0.10.0
|
||||||
|
ujson==2.0.3
|
||||||
|
uvloop==0.14.0
|
||||||
|
websockets==8.1
|
||||||
|
wrapt==1.12.1
|
Loading…
Reference in New Issue