...(중략)

app = Flask(__name__)

run_with_ngrok(app)

 

@app.route('/')

def index():

  return render_template('index.html')

 

@app.route('/list')

def list():

  keyword = request.args.get('keyword', default = 'coronafact'type = str)

  limit = request.args.get('limit', default = '10'type = str)

    

  conn = db_access()

    

  data = exec_list(conn,keyword,limit)

 

  session = {}

 

  session['keyword'] = str(keyword)

  session['limit'] = str(limit)

  

  return render_template('/coronafact.html',data=data,session=session)



app.run()

 

자세한 소스는 아래의 사이트를 참고하세요

https://github.com/gyunseul9/colabweb

Posted by 앤비
,

 

... (중략)

 

class create_user(Resource):

def get(self):

#return {'status':'success'}

try:

parser = reqparse.RequestParser()

parser.add_argument('uid', type=str)

parser.add_argument('name', type=str)

parser.add_argument('tel', type=str)

parser.add_argument('birthday', type=str)

parser.add_argument('pid', type=str)

args = parser.parse_args()

 

uid = args['uid']

name = args['name']

tel = args['tel']

birthday = args['birthday']

pid = args['pid']

 

# print(uid,name,tel,birthday,pid)

 

conn = pymysql.connect(

host=HOST,

user=USER,

password=PASSWORD,

db=DATABASE,

charset=CHARSET,

port=int(PORT),

cursorclass=pymysql.cursors.DictCursor)

 

# print(conn)

 

cnt = exec_select(conn,uid)

 

if cnt:

return {'StatusCode': '1000', 'Message': 'The account exists'}

else:

exec_insert(conn,uid,name,tel,birthday,pid)

return {'StatusCode': '1100', 'Message': 'You have created an account. ('+uid+')'}

 

except Exception as e:

with open(ERR_URI,'a') as file:

file.write('{} You got an error: {}\n'.format(datetime.today().strftime('%Y-%m-%d %H:%M:%S'),str(e)))

 

소스는 아래의 사이트를 참고하세요

https://github.com/gyunseul9/colabapi

Posted by 앤비
,

 

import pymysql

import requests

import configparser

from bs4 import BeautifulSoup

from datetime import datetime

from google.colab import drive

from xml.etree import ElementTree as et

 

...(중략)

 

 

area = {

    1:['경기',31],

    2:['강원',17],

    3:['충북',11],

    4:['서울',25],

    5:['부산',16],

    6:['대구',10],

    7:['인천',9],

    8:['광주',5],

    9:['대전',5],

    10:['울산',5],

    11:['충남',15],

    12:['전북',14],

    13:['전남',21],

    14:['경북',14],

    15:['경남',18],

    16:['제주',2],

    17:['세종',1]

    }

 

numOfRows = area.get(15)[1#지역 수

sidoName = area.get(15)[0#경남

 

params = {'pageNo'1'numOfRows': numOfRows, 'sidoName': sidoName, 'searchCondition''HOUR'}

 

resp = requests.get(URL+'?serviceKey='+change_keyword(SERVICEKEY), params=params)

 

# print(resp.text)

 

with open(RST_URI,'w'as file:

  file.write(resp.text)

 

data_collection(sidoName, RST_URI)

 

(자세한 소스는 아래의 사이트에서 참고하세요)

https://github.com/gyunseul9/colabdust

Posted by 앤비
,