EmilZach / Sentence-Crusher

A Python game for crushing sentences.
0 stars 1 forks source link

Implement "flask.request" - "post" data to server, "get" data from server #4

Closed Arxcis closed 8 years ago

Arxcis commented 8 years ago

When a program speaks with a web-application - our game.py and our flask-web-server.py) - it does so with HTTP requests.

There are two main HTTP request types - the HTTP GET method and HTTP POST method. GET is meant for fetching something from the server. A GET request implies that no side effects will happen when the server receives our request. Side effects may be changing something in the database for instance.

To do that, we use the POST request. https://github.com/technocake/flask-eksempel/blob/master/httpclient.py

get_highscore_list()

In the flask webserver, the function get_highscore_list() should return the current list of higscores from the database. It should return this in a format that is good for programs to read, not HTML, preferably text. (maybe JSON). This will be used by the game program to ask the server for the highscore-list and then show this data to the player.

add_higscore(...)

The add_highscore(...) function in the webserver should accept post requests from the game program containing data for a new highscore. [Jonas, can you fill in the details about the data in a game result / highscore? name, time, points. etc]

technocake commented 8 years ago

Here is example of retrieving POST requests in flask: https://github.com/technocake/flask-eksempel/blob/master/webserver.py#L105-L130

raglew commented 8 years ago

I think this issue can be closed. Scores can now be posted to the server and stored, and a list of scores can be returned to the game client.

Arxcis commented 8 years ago

Fantastic work! :)

  1. mar. 2016 8.51 p.m. skrev "raglew" notifications@github.com:

Closed #4 https://github.com/EmilZach/Sentence-Crusher/issues/4.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/EmilZach/Sentence-Crusher/issues/4#event-604581053

raglew commented 8 years ago

Thanks Robin. By the way, who is Kjell? Are you guys related? If so, greetings from me. Nice to have another man on board :)

raglew commented 8 years ago

oops... thanks arxcis... jonas!

Arxcis commented 8 years ago

Kjell is just me, using my brothers computer, forgetting to change user-name

  1. mar. 2016 9.22 p.m. skrev "raglew" notifications@github.com:

Thanks Robin. By the way, who is Kjell? Are you guys related? If so, greetings from me. Nice to have another man on board :)

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/EmilZach/Sentence-Crusher/issues/4#issuecomment-202127426

raglew commented 8 years ago

Too bad.. would be nice to have your brother on board. Can he program?

Arxcis commented 8 years ago

Trying to inspire him , but its difficult. He prefers to use games, not make them..

  1. mar. 2016 9.27 p.m. skrev "raglew" notifications@github.com:

Too bad.. would be nice to have your brother on board. Can he program?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/EmilZach/Sentence-Crusher/issues/4#issuecomment-202127789

raglew commented 8 years ago

Perhaps one day he will see the light :)