-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
32 lines (26 loc) · 966 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask, request, jsonify, render_template, send_from_directory
from flask_cors import CORS
from menu_choice import choice_lunch_menu
import requests
import json
import os
from dotenv import load_dotenv
import sys
app = Flask(__name__, static_url_path='/static')
CORS(app)
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
items = request.form.getlist('items')
n = int(request.form.get('n', 1))
if isinstance(n, int) and n <= 100000:
n = int(request.form.get('n', 1))
else:
message = "뽑기 횟수란에는 100000 이하의 자연수만 입력 가능합니다."
return jsonify(message), 400
result = choice_lunch_menu(*items, n=n)
return jsonify(result), 200
return render_template('index.html')
if __name__ == '__main__':
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port)