1seok2

get result

......@@ -48,7 +48,7 @@ def get_list(insta_id, driver):
def crawler_instagram(insta_id):
driver = webdriver.Chrome(executable_path='./chromedriver')
driver = webdriver.Chrome(executable_path='/Users/choewonseog/Documents/check-your-instagram/crawler/chromedriver')
driver.get(url=INSTAGRAM_URL)
time.sleep(4)
......
import os
from flask import Flask, render_template, request
from flask import Flask, render_template, request, jsonify
from crawler.crawler_instagram import crawler_instagram
......@@ -16,12 +16,20 @@ def home():
return render_template('index.html')
@app.route("/update", methods=["POST"])
def check():
insta_id = request.form['insta_id']
@app.route("/update", methods=["GET"])
def update():
insta_id = request.args.get('insta_id')
crawler_instagram(insta_id)
data = {
"insta_id" : insta_id
}
return jsonify(data)
@app.route("/hello", methods=["GET"])
def hello():
return "hello"
if __name__ == "__main__":
print("-" * 60)
......
......@@ -5,9 +5,25 @@
</head>
<body>
<h1>메인 화면</h1>
<form action="/check" method="POST">
<input id="insta_id" placeholder="id" type="text" name="insta_id"/>
<button>제출</button>
</form>
<input id="insta_id" placeholder="id" type="text" name="insta_id"/>
<button id="submit_id">제출</button>
<script>
const button = document.querySelector('#submit_id')
const input = document.querySelector('#insta_id')
button.addEventListener('click',async () => {
let result = null;
try {
result = await (await fetch('http://localhost:5000/update?insta_id=' + input.value)).json()
} catch (e) {
console.log(e)
} finally {
if(result) {
console.log(result.insta_id)
}
}
})
</script>
</body>
</html>
\ No newline at end of file
......