# as that of commit proceeds. db.session.rollback() raise finally: # close the Session. This will expunge any remaining # objects as well as reset any existing SessionTransaction # state. Neither of these steps are usually essential. # However, if the commit() or rollback() itself experienced # an unanticipated internal failure (such as due to a mis-behaved # user-defined event handler), .close() will ensure that # invalid state is removed. db.session.close() # raise @app.route('/add') def add(): todo = Todo('title', 'text') db.session.add(todo) db.session.commit() return "hello" @app.route('/') def upd(): bal() return "hello" if __name__ == '__main__': app.run()
req=requests.get\ ('http://rumahkode.wordpress.com') # req=requests.get\ # ('https://www.crummy.com/software/BeautifulSoup/bs4/doc/#navigating-the-tree') c=req.content soup=BeautifulSoup(c) # soup=BeautifulSoup('page/'+ url) bacah3=soup.find_all('h2') # bacah3=soup.find_all('title') if isi_hal is None: # arahkan ke halaman 404 return "Hal tdk ditemukan !".format(url) if isi_hal is not None: isi_hal=isi_hal isi_semua=isi_semua bacah3=bacah3 return render_template('page/page.html', TITLE='Flask Web App', \ isinya=isi_hal,bacah3=bacah3,isi_semua=isi_semua) # return render_template('page/page.html', TITLE='Flask Web App', \ # isinya=isi_hal,isi_semua=isi_semua) if __name__ == '__main__': app.run(debug=True, port=5555)
current_user = get_jwt_identity() user = Users.query.filter_by(phone=current_user).first() if not user: return jsonify(status=400, msg='none data'), 200 return_arry = {} return_arry['이름'] = user.name return_arry['학교코드'] = user.schoolCode return_arry['생일'] = user.birthDay return_arry['지역'] = user.region return_arry['자가진단 시간'] = user.time return json.dumps(return_arry, ensure_ascii=False) @app.route('/api/getnotification', methods=['GET']) def getNotifiation(): notify = notification.query.first() if not notify: return jsonify(status=200, msg="항상 사용해주셔서 감사합니다!"), 200 return jsonify(status=200, msg=notify.data), 200 if __name__ == '__main__': app.debug = True app.run(host='0.0.0.0', port=5000)
from setting import app import views app.add_url_rule('/','home',views.index) app.add_url_rule('/upload_image','upload_image',views.upload_image,methods=['POST']) if __name__ == '__main__': app.run(debug=False,use_reloader=True)
@app.route('/about') def about(): isi_about=Page.query.filter_by(title='About').first() if isi_about is not None: aboutnya = isi_about menu=Menu.query.order_by('order') return render_template('about.html',TITLE='Flask Web App',Aboutnya=aboutnya, global_vars=global_vars,MENU=menu) @app.route('/page/<url>') def page(url=None): isi_hal = Page.query.filter(Page.url=='page/'+ url).first() isi_semua=Page.query.filter(Page.title != 'homepage' ,Page.title != 'about').all() if isi_hal is None: # arahkan ke halaman 404 return "Hal tdk ditemukan !".format(url) if isi_hal is not None: isi_hal=isi_hal isi_semua=isi_semua return render_template('page/page.html', TITLE='Flask Web App', \ isinya=isi_hal,isi_semua=isi_semua) if __name__ == '__main__': app.run(debug=True, port=4444)
# endpoint to fetch an interview schedule time of a candidate with list of interviewers @app.route ( "/schedule_interview", methods=[ 'GET' ] ) def get_schedule_interview ( ): return schedule_logic.get_schedule_interviews ( ) # endpoint to reset the dbs @app.route ( "/reset_scheduler", methods=[ 'GET', 'POST' ] ) def reset_application ( ): return schedule_logic.reset_scheduler_dbs_for_next_week ( ) @app.errorhandler ( status.HTTP_409_CONFLICT ) def handle_client_request_conflict ( error ): return error, status.HTTP_409_CONFLICT @app.errorhandler ( status.HTTP_500_INTERNAL_SERVER_ERROR ) def handle_server_internal_error ( error ): return error, status.HTTP_500_INTERNAL_SERVER_ERROR @app.errorhandler ( status.HTTP_404_NOT_FOUND ) def page_not_found ( error ): return "The page user has requested doesn't exist", status.HTTP_404_NOT_FOUND if __name__ == '__main__': app.run ( debug=False )
req=requests.get\ ('http://rumahkode.wordpress.com') # req=requests.get\ # ('https://www.crummy.com/software/BeautifulSoup/bs4/doc/#navigating-the-tree') c = req.content soup = BeautifulSoup(c) # soup=BeautifulSoup('page/'+ url) bacah3 = soup.find_all('h2') # bacah3=soup.find_all('title') if isi_hal is None: # arahkan ke halaman 404 return "Hal tdk ditemukan !".format(url) if isi_hal is not None: isi_hal = isi_hal isi_semua = isi_semua bacah3 = bacah3 return render_template('page/page.html', TITLE='Flask Web App', \ isinya=isi_hal,bacah3=bacah3,isi_semua=isi_semua) # return render_template('page/page.html', TITLE='Flask Web App', \ # isinya=isi_hal,isi_semua=isi_semua) if __name__ == '__main__': app.run(debug=True, port=5555)