Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Feeding_Inc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
m3-shakeel
Feeding_Inc
Commits
97222475
Commit
97222475
authored
2 years ago
by
m3-shakeel
Browse files
Options
Downloads
Plain Diff
Merge branch 'farhan_upload_csv' into 'main'
main with csv See merge request
!1
parents
c14ffcde
2ae58958
Branches
Branches containing commit
No related tags found
1 merge request
!1
main with csv
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app.js
+22
-10
22 additions, 10 deletions
src/app.js
src/app.py
+40
-11
40 additions, 11 deletions
src/app.py
src/index.html
+11
-4
11 additions, 4 deletions
src/index.html
with
73 additions
and
25 deletions
src/app.js
+
22
−
10
View file @
97222475
const
submitButton
=
document
.
querySelector
(
"
#submit-button
"
);
const
uploadForm
=
document
.
getElementById
(
'
uploadForm
'
);
const
firstNameInput
=
document
.
querySelector
(
"
#first-name
"
);
const
csvFile
=
document
.
getElementById
(
'
csvFile
'
);
const
lastNameInput
=
document
.
querySelector
(
"
#last-name
"
);
const
csvDataDiv
=
document
.
getElementById
(
'
csvData
'
);
submitButton
.
addEventListener
(
"
click
"
,
()
=>
{
uploadForm
.
addEventListener
(
'
submit
'
,
async
function
(
e
)
{
const
firstName
=
firstNameInput
.
value
;
e
.
preventDefault
();
const
lastName
=
lastNameInput
.
value
;
axios
.
post
(
"
http://127.0.0.1:5000
"
,
{
firstName
,
lastName
}).
then
(
response
=>
{
const
formData
=
new
FormData
();
document
.
querySelector
(
"
h1
"
).
innerHTML
=
response
.
data
.
fullName
;
formData
.
append
(
'
csvFile
'
,
csvFile
.
files
[
0
]);
try
{
const
response
=
await
axios
.
post
(
'
http://127.0.0.1:5000/upload
'
,
formData
,
{
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
}
});
});
// Display the CSV data in the csvDataDiv
csvDataDiv
.
innerHTML
=
response
.
data
;
}
catch
(
error
)
{
console
.
error
(
error
);
}
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/app.py
+
40
−
11
View file @
97222475
from
flask
import
Flask
,
request
,
jsonify
# from flask import Flask, render_template, request
# import csv
app
=
Flask
(
__name__
)
import
pyodbc
@app.route
(
"
/
"
,
methods
=
[
"
POST
"
])
# app = Flask(__name__)
def
full_name
():
data
=
request
.
get_json
()
first_name
=
data
.
get
(
"
firstName
"
)
last_name
=
data
.
get
(
"
lastName
"
)
full_name
=
f
"
{
first_name
}
"
return
jsonify
({
"
fullName
"
:
full_name
})
if
__name__
==
"
__main__
"
:
with
pyodbc
.
connect
(
app
.
run
()
Trusted_Connection
=
'
No
'
,
Server
=
'
uwe-sdgp.database.windows.net,1433
'
,
User
=
'
fi_developer
'
,
Password
=
'
Eggyweggy156
'
,
Database
=
'
feeding_inc
'
)
as
conn
:
with
conn
.
cursor
()
as
cursor
:
cursor
.
execute
(
"
SELECT * FROM fid_patients
"
)
row
=
cursor
.
fetchone
()
while
row
:
print
(
str
(
row
[
0
])
+
"
"
+
str
(
row
[
1
]))
row
=
cursor
.
fetchone
()
# @app.route('/')
# def index():
# return render_template('index.html')
# @app.route('/upload', methods=['POST'])
# def upload():
# csv_file = request.files['csvFile']
# if csv_file:
# csv_data = csv_file.stream.read().decode('utf-8')
# csv_rows = csv_data.split('\n')
# csv_table = '<table>'
# for row in csv_rows:
# csv_table += '<tr>'
# csv_cols = row.split(',')
# for col in csv_cols:
# csv_table += f'<td>{col}</td>'
# csv_table += '</tr>'
# csv_table += '</table>'
# return csv_table
# return 'Error: No CSV file provided'
# if __name__ == '__main__':
# app.run(debug=True)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/index.html
+
11
−
4
View file @
97222475
...
@@ -4,13 +4,20 @@
...
@@ -4,13 +4,20 @@
<meta
charset=
"UTF-8"
/>
<meta
charset=
"UTF-8"
/>
<title>
Hello World!
</title>
<title>
Hello World!
</title>
<link
rel=
"stylesheet"
href=
"index.css"
/>
<link
rel=
"stylesheet"
href=
"index.css"
/>
<script
src=
"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"
></script>
</head>
</head>
<body>
<body>
<p>
Welcome to your Electron application!
<h1></h1></p>
<p>
Welcome to your Electron application!
<h1></h1></p>
<input
type=
"text"
id=
"first-name"
>
<input
type=
"text"
id=
"last-name"
>
<h1>
CSV Viewer
</h1>
<button
id=
"submit-button"
>
Submit
</button>
<form
id=
"uploadForm"
enctype=
"multipart/form-data"
>
<script
src=
"https://unpkg.com/axios/dist/axios.min.js"
></script>
<input
type=
"file"
id=
"csvFile"
name=
"csvFile"
>
<button
type=
"submit"
>
Upload
</button>
</form>
<div
id=
"csvData"
></div>
<script
src=
"app.js"
></script>
<script
src=
"app.js"
></script>
</body>
</body>
</html>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment