error 404 on web.py subapps. How to handle urls? -


last time wrote answer fast , efficient, here go again.

i got these 3 files, 2 .py , html. thing reason error 404. it's url handing issue. here code

# encoding: utf-8  import web import os import gettext import signup import verify_email  urls = (         "/", 'index',         "/sign-up", signup.app_signup,         "/verify_email", verify_email.app_verify_email         )  # internacionalización: current_directory = os.path.abspath(os.path.dirname(__file__)) locales_directory = current_directory + '/i18n' gettext.install('messages', locales_directory, unicode = true) gettext.translation('messages', locales_directory, languages = ['es']).install(true)  web.config.debug = false app = web.application(urls, locals()) session = web.session.session(app, web.session.diskstore('sessions'))   db = web.database(dbn='postgres', user='zoosalud', pw='pbf8zcxd4gzumhrxd8asjfhn', db='zoosalud')  def session_hook():     web.ctx.session = session     web.ctx.db = db     web.ctx.render = render  app.add_processor(web.loadhook(session_hook))  render = web.template.render('views/', globals = {'session': session, 'db': db, '_': _})  class index:     def get(self):         user_input = web.input()         user_input.names = ''         user_input.surnames = ''         user_input.nin = ''         user_input.address = ''         user_input.municipality = 0         user_input.phone = ''         user_input.email = ''         session.user_input = user_input         session.errors = []         return render.access()  if __name__ == "__main__":     app.run() 

here sub app

# encoding: utf-8  import bcrypt import email_setup import uuid import web   urls = (     "/", "signup"     )  class signup:      def post(self):         user_input = web.input()          web.ctx.session.errors = []         user = web.ctx.db.select('role', where="email='" + user_input.email + "'")         if user:             web.ctx.session.errors.append('email_taken')         user = web.ctx.db.select('role', where="nin='" + user_input.nin + "'")         if user:             web.ctx.session.errors.append('nin_taken')         if user_input.password != user_input.confirm_password:             web.ctx.session.errors.append('passwords_not_match')         if user_input.municipality == '0':             web.ctx.session.errors.append('unselected_municipality')         if web.ctx.session.errors:             web.ctx.session.user_input = user_input             return web.ctx.render.access()   app_signup = web.application(urls, locals()) 

and html

<form method=post action="sign-up">         <ul>             <li><input name=names required maxlength=24 placeholder=$_('name') value="$session.user_input.names"></li>         <li><input name=surnames required maxlength=24 placeholder=$_('surname') value="$session.user_input.surnames"></li>         <li><input name=nin requiered maxlength=12 placeholder=$_('nin') value="$session.user_input.nin"></li>         <li><input name=address required maxlenght=64 placeholder=$_('address') value="$session.user_input.address"></li>         <li><select id=municipality name=municipality>             <option value=0>$_('municipality'):</option>             $for municipality in municipalities:                 <option value=$municipality.id>$municipality.name</option>         </select></li>         <li><input name=phone required maxlength=10 placeholder=$_('phone') value=$session.user_input.phone></li>         <li><input name=email type=email required maxlenght=254 placeholder=$_('email') value=$session.user_input.email></li>         <li><input name=password type=password required placeholder=$_('password')></li>         <li><input name=confirm_password type=password required placeholder=$_('confirm_password')></li>         <li><input type=submit value="$_('sign_up')"></li> </ul> 

the problem mention error404 when map "/" in subapp, weird because when map "" work, need map can path get, , solution not work in long term.

thanks in advance guys.

you may change subapp mapping "/?", "signup" should work , without trailing slash.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -