|
@@ -10,43 +10,6 @@ from config import config
|
|
|
|
|
|
routes = web.RouteTableDef()
|
|
|
|
|
|
[email protected]('/mkuser')
|
|
|
-async def debug(request):
|
|
|
- from db import db, User
|
|
|
- from tools import hash_password
|
|
|
-
|
|
|
- u = await db.create(User, username='cirno', password=hash_password('cirno'), ip_address='127.0.0.1')
|
|
|
-
|
|
|
- return web.json_response({'i':u.id})
|
|
|
-
|
|
|
[email protected]('/mkuser2')
|
|
|
-async def debug(request):
|
|
|
- from db import db, User
|
|
|
- from tools import hash_password
|
|
|
-
|
|
|
- u = await db.create(User, username='cirno9', password=hash_password('cirno9'), ip_address='127.0.0.1')
|
|
|
-
|
|
|
- return web.json_response({'i':u.id})
|
|
|
-
|
|
|
[email protected]('/mkvid')
|
|
|
-async def debug(request):
|
|
|
- from db import db, Video, User, VideoTag, Tag
|
|
|
-
|
|
|
- u = await db.get(User.select().where(User.username == 'cirno'))
|
|
|
- v = await db.create(Video, video='test', thumbnail='/static/thumbs/default.png', uploader=u)
|
|
|
-
|
|
|
- tag1 = await db.get_or_create(Tag, tag='test1')
|
|
|
- tag2 = await db.get_or_create(Tag, tag='test2')
|
|
|
- tag3 = await db.get_or_create(Tag, tag='test3')
|
|
|
- tag4 = await db.get_or_create(Tag, tag='test4')
|
|
|
-
|
|
|
- await db.create(VideoTag, video=v, tag=tag1[0])
|
|
|
- await db.create(VideoTag, video=v, tag=tag2[0])
|
|
|
- await db.create(VideoTag, video=v, tag=tag3[0])
|
|
|
- await db.create(VideoTag, video=v, tag=tag4[0])
|
|
|
-
|
|
|
- return web.json_response({'i':v.id})
|
|
|
-
|
|
|
@routes.get('/')
|
|
|
async def index(request):
|
|
|
return web.HTTPFound('/random')
|