62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
|
#!/usr/bin/env python3
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
"""
|
||
|
|
||
|
TODO
|
||
|
|
||
|
* Delete cookie if session does not match
|
||
|
|
||
|
* Delete entry/tag/jid combination row upon removal of a tag.
|
||
|
|
||
|
"""
|
||
|
|
||
|
import argparse
|
||
|
from blasta.http.instance import HttpInstance
|
||
|
from blasta.sqlite import SQLite
|
||
|
import json
|
||
|
import logging
|
||
|
from os.path import getsize, exists
|
||
|
import sys
|
||
|
import time
|
||
|
from typing import Optional
|
||
|
import urllib.parse
|
||
|
import uvicorn
|
||
|
import webbrowser
|
||
|
|
||
|
|
||
|
try:
|
||
|
import tomllib
|
||
|
except:
|
||
|
import tomli as tomllib
|
||
|
|
||
|
|
||
|
def main():
|
||
|
if not exists('main.sqlite') or not getsize('main.sqlite'):
|
||
|
SQLite.instantiate_database('main.sqlite')
|
||
|
accounts = {}
|
||
|
sessions = {}
|
||
|
http_instance = HttpInstance(accounts, sessions)
|
||
|
return http_instance.app
|
||
|
|
||
|
app = main()
|
||
|
|
||
|
# FIXME
|
||
|
if __name__ == 'blasta.__main__':
|
||
|
parser = argparse.ArgumentParser(
|
||
|
prog='blasta',
|
||
|
description='Blasta - A collaborative annotation system.',
|
||
|
usage='%(prog)s [OPTION]...')
|
||
|
parser.add_argument('-v', '--version', help='print version',
|
||
|
action='version', version='0.1')
|
||
|
parser.add_argument('-p', '--port', help='port number', dest='port')
|
||
|
parser.add_argument('-o', '--open', help='open an html browser', action='store_const', const=True, dest='open')
|
||
|
args = parser.parse_args()
|
||
|
port = args.port if args.port else 8000
|
||
|
uvicorn.run(app, host='localhost', port=port)
|
||
|
if args.open:
|
||
|
# TODO Check first time
|
||
|
webbrowser.open('http://localhost:{}/help/about'.format(port))
|
||
|
webbrowser.open_new_tab('http://localhost:{}'.format(port))
|
||
|
|