app.py
from flask import Flask, render_template, jsonify, request
app = Flask(__name__)
import requests
from bs4 import BeautifulSoup
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.dbsparta
## HTML을 주는 부분
@app.route('/')
def home():
return render_template('index.html')
@app.route('/memo', methods=['GET'])
def listing():
sample_receive = request.args.get('sample_give')
print(sample_receive)
return jsonify({'msg':'GET 연결되었습니다!'})
## API 역할을 하는 부분
@app.route('/memo', methods=['POST'])
def saving():
sample_receive = request.form['sample_give']
print(sample_receive)
return jsonify({'msg':'POST 연결되었습니다!'})
if __name__ == '__main__':
app.run('0.0.0.0',port=5000,debug=True)
'프로그래밍 > Python' 카테고리의 다른 글
MongoDB Sort ( 파이썬 db 호출 후 정렬) (0) | 2022.04.12 |
---|---|
ajax 골격, 로딩 후 실행 함수 (0) | 2022.04.08 |
Beautiful Soup 크롤링 (with 파이썬) (0) | 2022.04.07 |
flask 사용법 (with 파이썬) (0) | 2022.04.04 |
파이썬 (python) - 변수, 자료형, 함수, 조건문, 반복문 (0) | 2022.03.30 |