How can I upload the map.py to the app.py using html and python?

1

I am trying to upload my game to the local host 5002, but after the welcome of the user who has just connected, I can not upload the scenes and choices that have to be made.

I have this:

from flask import Flask, session, request
from flask import url_for, redirect, render_template
import map

app = Flask(__name__) #se need como parametro

@app.route('/', methods = ["POST"])
def login():
    user = request.form.get('name')
    return render_template("index.html", name = user)

@app.route('/', methods = ['GET'])
def hello():
    return render_template("form.html")

@app.route ('/', methods = ["POST"])
def game():
    session['scene'] = map.START.urlname
    return redirect(url_for('game_get'))
@app.route('/game', methods=['POST'])
def game_get():
thescene = map.SCENES[session['scene']]
return render_template('next_scene.html', scene=thescene)

and this is the map.py with the description of the scenes, the options and the .urlname:

class Scene(object):
    def __init__(self, title, urlname, description):
        self.title = title
        self.urlname = urlname
        self.description = description
        self.paths = {}

    def go(self, direction):
        default_direction = None
        if '*' in self.paths.keys():
            default_direction = self.paths.get('*')
        return self.paths.get(direction, default_direction)

    def add_paths(self, paths):
        self.paths.update(paths)


first_start = Scene("Alley", "first_start",
"""
Now, be very careful. You're a thief that just robbed a bank.
You're trapped in a dead-end-road that has an apple tree.
There are only two exits, at both ends of the street below you.
To the right, there's a rabid dog that would follow anything thatmoves.
To the left, a cop.
How do you elude the dangers and flee alive?
"""
)

and the options for each scene on the "accept" button

SCENES = {
first_start.urlname : first_start,
etc with the other scenes
}

but as I said, after I get the ("Hello A!") and print the first scene of my map in the / game with the "accept" button, by including something and clicking, it does not take me to the next scene does not show the message "input error, it is not an option" or the "You have died!". Only the Error appears:  Method Not Allowed The method is not allowed for the requested URL.

Any ideas on how to fix this?

    
asked by Sistemas Medioambientales 05.02.2018 в 17:04
source

0 answers