Skip to content

Commit

Permalink
[update]
Browse files Browse the repository at this point in the history
  • Loading branch information
boke0 committed Mar 3, 2021
1 parent 10c62c5 commit e102735
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 41 deletions.
1 change: 1 addition & 0 deletions docker/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ http {
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /log/access.log main;
client_max_body_size 10m;

sendfile off;
#tcp_nopush on;
Expand Down
2 changes: 2 additions & 0 deletions mitama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* 抽象化はするかどうか迷ってる(Pythonで抽象化がどれくらい尊いものかよくわかんない)
* argparseを入れようか迷ったけど、位置引数しか必要に成る予定が無いのでとりあえず入れてない
"""
import warnings
warnings.simplefilter("ignore")

import argparse
import mitama.commands
Expand Down
15 changes: 15 additions & 0 deletions mitama/project/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@
import importlib
from mitama.app import AppRegistry
from mitama.app.http import run_app
from getpass import getpass


def run(project, args):
port = args.port
project.port = port
run_app(project, project.port)

def auth(project, args):
from mitama.models import User
user = args.user
password = args.password
if password == "":
password = getpass("Password:")
try:
user = User.password_auth(user, password)
print(user.get_jwt())
sys.exit(0)
except Exception:
print("Authentication failed")
sys.exit(1)
4 changes: 4 additions & 0 deletions mitama/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def arg_parser(self):
cmd_run = subparser.add_parser("run", help="Start serving project")
cmd_run.add_argument("-p", "--port", help="serving port", type=int, default=8080)
cmd_run.set_defaults(handler=commands.run)
cmd_auth= subparser.add_parser("auth", help="Authenticate user identified by screen name and password")
cmd_auth.add_argument("-u", "--user", help="user's screen name", type=str)
cmd_auth.add_argument("-p", "--password", help="password", type=str, nargs="?", default="", const="")
cmd_auth.set_defaults(handler=commands.auth)
#cmd_cleandb = subparser.add_parser("cleandb", help="Clean up unused App's database")
#cmd_cleandb.add_argument("prefix", help="")
return self._arg_parser
Expand Down
42 changes: 1 addition & 41 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e102735

Please sign in to comment.