Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Menteur
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLN
Menteur
Commits
0f48bdc9
Unverified
Commit
0f48bdc9
authored
Apr 04, 2020
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: naming
parent
ebe04bfa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
app.py
server/app.py
+45
-0
No files found.
server/app.py
0 → 100644
View file @
0f48bdc9
from
fastapi
import
FastAPI
,
APIRouter
from
starlette.websockets
import
WebSocket
from
server.model.data
import
Game
,
Player
app
=
FastAPI
()
router
=
APIRouter
()
game
=
Game
()
@router.get
(
"/"
)
async
def
hello_world
():
return
"Hello, gentle[wo]man"
@router.post
(
"/join"
)
async
def
join
(
player_name
:
str
):
game
.
players
.
append
(
Player
(
player_name
))
@router.post
(
"/ready"
)
async
def
ready
():
pass
@router.post
(
"/play"
)
async
def
play
():
pass
@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}"
)
app
.
include_router
(
router
)
if
__name__
==
'__main__'
:
import
uvicorn
uvicorn
.
run
(
"app:app"
,
host
=
"0.0.0.0"
,
port
=
9042
,
reload
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment