Skip to content

Commit

Permalink
feat: run local without flask via arg
Browse files Browse the repository at this point in the history
  • Loading branch information
duhow committed Oct 24, 2024
1 parent 43a8c8e commit bf47255
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 5000

CMD ["python3", "app.py"]
ENTRYPOINT ["python3", "app.py"]
19 changes: 18 additions & 1 deletion app.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from mail_checker.validator import Validator
from mail_checker.const import debug_mode
import logging
import argparse
import json

app = Flask(__name__)

Expand Down Expand Up @@ -47,5 +49,20 @@ def check_email():

return jsonify(validator.dict)

def main():
parser = argparse.ArgumentParser(description='Mail Checker')
parser.add_argument('input', nargs='?', help='Email to validate or run the server')
args = parser.parse_args()

if args.input and '@' in args.input:
validate_email(args.input)
else:
app.run(host='0.0.0.0', debug=debug_mode)

def validate_email(email):
validator = Validator(email)
validator.run()
print(json.dumps(validator.dict))

if __name__ == '__main__':
app.run(host='0.0.0.0', debug=debug_mode)
main()

0 comments on commit bf47255

Please sign in to comment.