Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ExoVisnum2022-2023
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ivan.rigo
ExoVisnum2022-2023
Commits
e0ceeeb7
Commit
e0ceeeb7
authored
2 years ago
by
ivan.rigo
Browse files
Options
Downloads
Patches
Plain Diff
Started Com between html/Python
parent
4e77088f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
OCR/Doc.txt
+0
-0
0 additions, 0 deletions
OCR/Doc.txt
OCR/__pycache__/apiOCR.cpython-310.pyc
+0
-0
0 additions, 0 deletions
OCR/__pycache__/apiOCR.cpython-310.pyc
OCR/apiOCR.py
+57
-0
57 additions, 0 deletions
OCR/apiOCR.py
with
57 additions
and
0 deletions
OCR/Doc.txt
0 → 100644
+
0
−
0
View file @
e0ceeeb7
This diff is collapsed.
Click to expand it.
OCR/__pycache__/apiOCR.cpython-310.pyc
0 → 100644
+
0
−
0
View file @
e0ceeeb7
File added
This diff is collapsed.
Click to expand it.
OCR/apiOCR.py
0 → 100644
+
57
−
0
View file @
e0ceeeb7
from
typing
import
Union
from
fastapi
import
FastAPI
,
WebSocket
from
fastapi.responses
import
HTMLResponse
app
=
FastAPI
()
html
=
"""
<!DOCTYPE html>
<html>
<head>
<title>Chat</title>
</head>
<body>
<h1>WebSocket Chat</h1>
<form action=
""
onsubmit=
"
sendMessage(event)
"
>
<input type=
"
text
"
id=
"
messageText
"
autocomplete=
"
off
"
/>
<button>Send</button>
</form>
<ul id=
'
messages
'
>
</ul>
<script>
var ws = new WebSocket(
"
ws://localhost:8000/ws
"
);
ws.onmessage = function(event) {
var messages = document.getElementById(
'
messages
'
)
var message = document.createElement(
'
li
'
)
var content = document.createTextNode(event.data)
message.appendChild(content)
messages.appendChild(message)
};
function sendMessage(event) {
var input = document.getElementById(
"
messageText
"
)
ws.send(input.value)
input.value =
''
event.preventDefault()
}
</script>
</body>
</html>
"""
@app.get
(
"
/
"
)
async
def
get
():
return
HTMLResponse
(
html
)
@app.websocket
(
"
/ws
"
)
async
def
websocket_endpoint
(
websocket
:
WebSocket
):
await
websocket
.
accept
()
while
True
:
data
=
await
websocket
.
receive_text
()
await
websocket
.
send_text
(
f
"
Message text was:
{
data
}
"
)
#Check WebSocket https://fastapi.tiangolo.com/uk/advanced/websockets/
\ No newline at end of file
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