-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
41 lines (35 loc) · 1.19 KB
/
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
33
34
35
36
37
38
39
40
41
from flask import Flask, render_template, request
import subprocess
app = Flask(__name__)
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html>
<head>
<title>Our Company</title>
</head>
<body>
<h1>제주도 날씨</h1>
<h2></h2>
<p>위치를 입력해주세요</p>
<form action="/process" method="post">
<h2>
<input type="text" name="location" 위치="위치" placeholder="현재 위치">
</h2>
<button type="submit">입력</button>
</form>
</body>
</html>
'''
@app.route('/process', methods=['POST'])
def process():
location = request.form['location'] # Get the value of the 'location' input
output = execute_ex_script(location) # Execute ex.py with the location and get the output
return render_template('output.html', location=location, output=output)
def execute_ex_script(location):
command = ['python', 'naver_weather.py', location]
result = subprocess.run(command, capture_output=True, text=True)
return result.stdout
if __name__ == '__main__':
app.run()