main
mika
python
3 years ago
868 B
3
Indexable
Never
from flask import Flask, jsonify, session, render_template, request app = Flask(__name__) app.secret_key = 'ini rahasia' users = [] @app.route('/', methods=['GET']) def index(): if 'counter' not in session.keys(): session['counter'] = 0 else: session['counter'] += 1 return 'Counter: ' + str(session['counter']) @app.route('/webix', methods=['GET']) def webix(): return render_template('index.html') @app.route('/select', methods=['GET']) def select(): return jsonify({'data': users}) @app.route('/insert', methods=['POST']) def insert(): username = request.form.get('username') email = request.form.get('email') users.append({ 'username': username, 'email': email }) return jsonify({'message': 'Berhasil Insert'}) if __name__ == '__main__': app.run(host="localhost", port=8080 , debug=True)