Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb45b48

Browse files
authored
Add files via upload
1 parent ae99ff3 commit fb45b48

26 files changed

+7678
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from flask import Flask
2+
3+
app = Flask(__name__)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from app import app
2+
from flaskext.mysql import MySQL
3+
4+
mysql = MySQL()
5+
6+
# MySQL configurations
7+
app.config['MYSQL_DATABASE_USER'] = 'root'
8+
app.config['MYSQL_DATABASE_PASSWORD'] = 'root'
9+
app.config['MYSQL_DATABASE_DB'] = 'roytuts'
10+
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
11+
mysql.init_app(app)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pymysql
2+
from app import app
3+
from db_config import mysql
4+
from flask import flash, render_template, jsonify
5+
6+
@app.route('/')
7+
def home():
8+
return render_template('calendar_events.html')
9+
10+
@app.route('/calendar-events')
11+
def calendar_events():
12+
conn = None
13+
cursor = None
14+
try:
15+
conn = mysql.connect()
16+
cursor = conn.cursor(pymysql.cursors.DictCursor)
17+
cursor.execute("SELECT id, title, url, class, UNIX_TIMESTAMP(start_date)*1000 as start, UNIX_TIMESTAMP(end_date)*1000 as end FROM event")
18+
rows = cursor.fetchall()
19+
resp = jsonify({'success' : 1, 'result' : rows})
20+
resp.status_code = 200
21+
return resp
22+
except Exception as e:
23+
print(e)
24+
finally:
25+
cursor.close()
26+
conn.close()
27+
28+
if __name__ == "__main__":
29+
app.run()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You can go through the tutorial https://www.roytuts.com/bootstrap-calendar-events-demo-using-python-flask-mysql/

0 commit comments

Comments
 (0)