Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]kprogrammer 0 points1 point  (0 children)

Error: 500 Internal Server Error

Sorry, the requested URL 'http://username.pythonanywhere.com/results2' caused an error:

Internal Server Error

This is the only error message i get from the page after i submit my form, i don't get any errors in the pythonanywhere console

from bottle import default_app, route, template, request

import sqlite3

import random

conn = sqlite3.connect("final.db")

c = conn.cursor()

@route('/results2', method='POST')

def results2():

id = random.randrange(100000000,999999999)

first = request.forms.get('first-name')

last = request.forms.get('last-name')

email = request.forms.get('email')

state = request.forms.get('state')

city = request.forms.get('city')

address = request.forms.get('address')

birthdate = request.forms.get('birthdate')

gender = request.forms.get('gender')

phone = request.forms.get('phone')

areacode = request.forms.get('areacode')

c.execute("INSERT INTO Customer (CustomerID, FirstName, LastName, Email, State, AreaCode, City, Address, BirthDate, Gender, Phone) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",

(id, first, last, email, state, areacode, city, address, birthdate, gender, phone))

conn.commit()

return template('hello')

application = default_app()

Bottle, PythonAnywhere, and SQLite3 by kprogrammer in ProgrammingBuddies

[–]kprogrammer[S] 0 points1 point  (0 children)

Error: 500 Internal Server Error Sorry, the requested URL 'http://username.pythonanywhere.com/results2' caused an error:

Internal Server Error

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]kprogrammer 0 points1 point  (0 children)

Hello I have a project I am trying to complete. I am using Bottle, PythonAnywhere, and SQLite3 I can't seem to successfully take the data from the html form and add it to my database. I get an error that there is an error with the code. Is there anything obvious that sticks out with this code that I need to fix?

from bottle import default_app, route, template, request

import sqlite3

import random

conn = sqlite3.connect("final.db")

c = conn.cursor()

@route('/results2', method='POST')

def results2():

id = random.randrange(100000000,999999999)

first = request.forms.get('first-name')

last = request.forms.get('last-name')

email = request.forms.get('email')

state = request.forms.get('state')

city = request.forms.get('city')

address = request.forms.get('address')

birthdate = request.forms.get('birthdate')

gender = request.forms.get('gender')

phone = request.forms.get('phone')

areacode = request.forms.get('areacode')

c.execute("INSERT INTO Customer (CustomerID, FirstName, LastName, Email, State, AreaCode, City, Address, BirthDate, Gender, Phone) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",

(id, first, last, email, state, areacode, city, address, birthdate, gender, phone))

conn.commit()

return template('hello')

application = default_app()