Reputation: 21
from crypt import methods
from distutils.log import debug
from flask import Flask, render_template, request, url_for, redirect
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']= 'sqlite:///reg.db'
db = SQLAlchemy(app)
class Todo(db.Model):
name = db.Column(db.String(200), nullable=False)
Bdate = db.Column(db.Integer(), nullable=False)
Gender = db.Column(db.String(6), nullable = False)
Class = db.Column(db.String(9), nullable = False)
Registration = db.Column(db.Integer(), primary_key = True)
date_created = db.Column(db.DateTime, default= datetime.utcnow)
def __repr__(self):
return '<Task %r>' % self.id
SQLALCHEMY_TRACK_MODIFICATIONS = False #to supress warning in terminal
@app.route('/', methods=['POST','GET'])
def index():
if request.method == "POST":
pass
task_content = request.form['card-body']
new_task = Todo(content = task_content)
try:
db.session.add(new_task)
db.session.commit()
return redirect('/')
except:
return "Their Was An Error"
else:
task = Todo.query.order_by(Todo.date_created).all()
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True)
Here is my code i dont know how to modify the code to get it run on my Windows. Its my first day of learning flask Please help me out
from crypt import methods
line 9, in <module>
raise ImportError("The crypt module is not supported on Windows")
ImportError: The crypt module is not supported on Windows
this is the error i m getting. Its mostly becasue of POST AND GET in method I guess and i m unable to solve this. I m working on db connection to form in html with the help of Youtube and the guy isusing UNIX so doesnt have any problem but my windows suks here.
Upvotes: 1
Views: 806
Reputation: 4383
you had automatically made this import: from crypt import methods
when you were typing this line of code @app.route('/', method...
. but this crypt is a Python module used to check Unix passwords and you are using windows. anyway it has nothing to do with flask just delete this line from crypt import methods
Upvotes: 0