# file app/app.py from flask import request, jsonify from __init__ import application from helper import * @application.route('/v1/status', methods=['GET']) def get_status(): foo_method() return jsonify({"data" : "SUCCESSFUL"}) if __name__ == '__main__': application.run(debug=True, host='127.0.0.1', port=5000)
@application.route('/edit_biography', methods=['GET', 'POST']) def edit_biography(): id = request.form['pk'] user = User.query.get(id) user.biography = request.form['value'] db.session.commit() result = {} return json.dumps(result) def init_db(): db.create_all() '''db.drop_all() user = User(username='******', firstname='Prusilla', lastname='Anonymous', password=hash_password('maska'), email='*****@*****.**', tagline='Incredibly fast programmer', biography='I love Python very much!', avatar='http://placekitten.com/500/300') user.portfolio.append(Portfolio(title='awesome', description='Great description', tags='python,django')) user.portfolio.append(Portfolio(title='awesome123', description='Great description123', tags='java,javascript')) db.session.add(user) db.session.commit()''' if __name__ == '__main__': init_db() application.run(debug=True, host='0.0.0.0', port=9000)
db.session.commit(); return render_template("code.html",username = user); return render_template("FA.html",form =Auth); @application.route("/register",methods=['GET','POST']) def register(): register = RegisterForm(); if register.validate_on_submit(): details = Logindb(register.Username.data, register.Password.data); db.session.add(details); db.session.commit(); return render_template("success.html",User = register.Username.data); return render_template("Register.html",form = register); @application.route("/out/<user>",methods=['GET']) def out(user): print user; details = Logindb.query.filter_by(username=user).first(); details.Loginstat ="logged out"; db.session.add(details); db.session.commit(); return redirect("/"); if __name__ == "__main__": db.create_all(); db.session.commit(); api.add_resource(delcode,"/delcode/<username>") api.add_resource(add_code_api, "/add_code_api/<username>/<string:code>"); api.add_resource(login_api, '/login_api/<id>/<password>'); application.run(host='0.0.0.0',debug = True);
# Run a test server. #from app import application from __init__ import application import sys if __name__ == '__main__': if len(sys.argv) == 2 and sys.argv[1] == "test": exit(0) application.run(host='0.0.0.0', port=8080, debug=True)
from charter import __init__ from __init__ import application as application if __name__ == "__main__": application.run()
transactionData['category'] = trans.category return jsonify({'transaction': transactionData}), 200 @application.route('/trans/', methods=['GET']) @token_required def getAllTransactions(currentUser): """ 12. This function returns all the transactions """ transs = Transaction.query.filter_by(userId=currentUser.id).all() # Collect necessary information for each transaction to display output = [] for trans in transs: transactionData = {'amount': trans.amount} if not trans.income: transactionData['amount'] = -1 * transactionData['amount'] transactionData['date'] = trans.date transactionData['category'] = trans.category transactionData['ID'] = trans.id output.append(transactionData) return jsonify({'transactions': output}), 200 if __name__ == '__main__': db.create_all() application.run(debug=True)
from __init__ import application if __name__ == '__main__': application.run(debug=True)