Browse Source

Allow user to specify database url

pull/1090/head
Hironsan 4 years ago
parent
commit
f3fc214170
1 changed files with 10 additions and 7 deletions
  1. 17
      app/doccano/doccano.py

17
app/doccano/doccano.py

@ -4,14 +4,18 @@ import subprocess
def main(): def main():
parser = argparse.ArgumentParser(prog='gfg', description='GfG article demo package.')
parser.add_argument('--username', type=str, default='admin')
parser.add_argument('--password', type=str, default='password')
parser.add_argument('--email', type=str, default='example@example.com')
parser.add_argument('--port', type=int, default=8000)
parser.add_argument('--workers', type=int, default=1)
parser = argparse.ArgumentParser(description='doccano.')
parser.add_argument('--username', type=str, default='admin', help='admin username')
parser.add_argument('--password', type=str, default='password', help='admin password')
parser.add_argument('--email', type=str, default='example@example.com', help='admin email')
parser.add_argument('--port', type=int, default=8000, help='port')
parser.add_argument('--workers', type=int, default=1, help='workers')
parser.add_argument('--database_url', type=str, default='sqlite:///doccano.db', help='data store')
args = parser.parse_args() args = parser.parse_args()
os.environ.setdefault('DEBUG', 'False')
os.environ.setdefault('DATABASE_URL', args.database_url)
print('Setup Database.') print('Setup Database.')
base = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) base = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
manage_path = os.path.join(base, 'manage.py') manage_path = os.path.join(base, 'manage.py')
@ -27,7 +31,6 @@ def main():
'--noinput'], shell=False) '--noinput'], shell=False)
print(f'Starting server with port {args.port}.') print(f'Starting server with port {args.port}.')
os.environ['DEBUG'] = 'False'
subprocess.call(['python', manage_path, 'runserver', f'0.0.0.0:{args.port}']) subprocess.call(['python', manage_path, 'runserver', f'0.0.0.0:{args.port}'])

Loading…
Cancel
Save