Commit 67976c4c authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Create getReadActivity

parent db58b364
......@@ -5,7 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/venv" />
<excludeFolder url="file://$MODULE_DIR$/API/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
<option value="N806" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
<option value="N806" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
from flask import Flask, redirect, url_for, render_template, request, jsonify, make_response
from API.model.colorModel import get_color_activities
from API.model.readModel import get_reading_activities
from API.routers.router import funtion_one
app = Flask(__name__)
# Initial Route
@app.route("/")
def home():
return render_template('home.html')
# Color Function Route (IT18218640)
@app.route("/getColorActivities")
def getColorActivities():
......@@ -19,11 +22,17 @@ def getColorActivities():
# Read Function Route (IT)
@app.route("/testings")
def checkothers():
return "testing funtions"
# Color Function Route (IT18218640)
@app.route("/reading")
def getReadActivities():
return get_reading_activities()
@app.route("/ru")
def abc():
response_val = funtion_one()
......@@ -34,7 +43,8 @@ def abc():
# return make_response(d, 200)
return response_val
if __name__ == "__main__":
app.run(host='192.168.8.101')
#app.run(host='192.168.8.100,port='5000', debug=True)
# app.run(debug=True)
\ No newline at end of file
# app.run(host='192.168.8.101')
# app.run(host='192.168.8.100,port='5000', debug=True)
app.run(debug=True)
......@@ -12,16 +12,17 @@ def create_con():
database="helply",
host="127.0.0.1",
user="root",
password="rp19970520"
password="12345678"
)
return db
def create_con_pandas():
db_connection_str = 'mysql+mysqlconnector://root:rp19970520@127.0.0.1/helply'
db_connection_str = 'mysql+mysqlconnector://root:12345678@127.0.0.1/helply'
db = create_engine(db_connection_str)
return db
def get_all_data(query):
data_dic = []
db = create_con()
......@@ -30,7 +31,7 @@ def get_all_data(query):
result = cursor.fetchall()
for row in result:
ob={
ob = {
"idcolorActivities": row[0],
"name": row[1],
"file": row[2],
......@@ -43,6 +44,27 @@ def get_all_data(query):
return jsonify(data_dic)
def get_reading_data(query):
db = create_con()
cursor = db.cursor()
cursor.execute(query)
result = cursor.fetchall()
#
# for row in result:
# ob = {
# "idcolorActivities": row[0],
# "name": row[1],
# "file": row[2],
# "des": row[3],
# "color": row[4],
# }
#
# data_dic.append(ob)
return result
def insert_data_pandas_df(pd_df, table_name):
db = create_con_pandas()
pd_df.to_sql(name=table_name, con=db, if_exists='append', index=False)
......@@ -69,7 +91,7 @@ def getDatas(query):
cursor.execute(query)
result = cursor.fetchall()
#idcolorActivities, name, image
# idcolorActivities, name, image
for row in result:
data_dic.add(row[0], ({"idcolorActivities": row[0], "name": row[1], "image": row[2]}))
......
from API.db.dbConnection import get_data
from API.db.dbConnection import get_reading_data
from flask import jsonify
def get_color_activities():
qry = 'SELECT * FROM readactivities'
def get_reading_activities():
data_dic = []
qry = 'SELECT * FROM reading'
response = get_data(qry)
result = get_reading_data(qry)
return response
\ No newline at end of file
for row in result:
ob = {
"id": row[0],
"round": row[1],
}
data_dic.append(ob)
return jsonify(data_dic)
......@@ -10,6 +10,7 @@ import Splash from '../screen/splash/Splash';
import Color from '../screen/Color';
import Blue from '../screen/Blue';
import Read from '../screen/Read';
import ReadActivity from '../screen/activity/readActivity';
const Stack = createNativeStackNavigator();
const AppRouter = () => {
......@@ -56,6 +57,11 @@ const AppRouter = () => {
name="Read"
component={Read}
/>
<Stack.Screen
options={{headerShown: false}}
name="ReadActivity"
component={ReadActivity}
/>
</Stack.Navigator>
</NavigationContainer>
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment