Week-1 Education Related Project

Week-1 Education Related Project

6 min read

It was my first encounter with flask; I searched out its implementation and how to set it up in the virtual environment. The project was given in zip folder and the primary and the must task was to set up the flask application in local host.

But how to set it up the command prompt was always showing same message every time and that was

C:\Users\Keshav Raturi\Desktop\eduthing>flask run
'flask' is not recognized as an internal or external command,
operable program or batch file.

I tried everything from very basic pip install flask to pip install almost everything but there not a single thing happened. What I thought was going through the below procedure to easily run that :

>pip install flask // xD
>python //to check that flask is working or not
>import flask //if after pressing enter everything works fine then its good to go..
>exit() //just to leave the shell
>mkdir [name] //As I was provided with the folder so I skipped this
>cd eduthing/
>set FLASK_APP = EduWonder.py
>set FLASK_DEBUG = 1 //debug in ON mode that is actually important 
>flask run  

But these steps were not enough README.md instructs us to download dependencies also and connecting it with database is the hardest part (only for me :[) and still working on it!

Finally after searching a lot through internet I come across the term “virtual environment”, oh shit! What’s this? Yes, only because of this I was able to run localhost. What I did was as follows:

> cd eduthing/
>py –m venv env // YES that’s how we creat virtualenv
>env\Scripts\activate
>pip  install flask
> set FLASK_APP = EduWonder.py
>flask run

Finally the message shown up was a huge relief for me that was :

C:\Users\Keshav Raturi\Desktop\eduthing\env\Scripts>flask run
 * Serving Flask app "EduWonder.py" (lazy loading)
 * Environment: development
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 161-961-287
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

And 200 was the sign that everything was going fine

127.0.0.1 - - [07/Jun/2020 15:51:41] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Jun/2020 15:51:41] "GET /static/landing.css HTTP/1.1" 200 -
127.0.0.1 - - [07/Jun/2020 15:51:41] "GET /static/College.jpg HTTP/1.1" 200 -
127.0.0.1 - - [07/Jun/2020 15:51:41] "GET /static/icon1.png HTTP/1.1" 200 -
127.0.0.1 - - [07/Jun/2020 15:51:47] "GET /getstarted/ HTTP/1.1" 200 -
127.0.0.1 - - [07/Jun/2020 15:51:47] "GET /static/loginreg.css HTTP/1.1" 200 -
127.0.0.1 - - [07/Jun/2020 15:51:47] "GET /static/bglogin.jpg HTTP/1.1" 200 -
127.0.0.1 - - [07/Jun/2020 16:14:58] "GET /admin/ HTTP/1.1" 404 -
127.0.0.1 - - [07/Jun/2020 16:14:58] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [07/Jun/2020 16:15:04] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [07/Jun/2020 16:15:08] "GET / HTTP/1.1" 200 –

But Unfortunately this didn’t remain for while registering I come across 500 this was all because of mysqlclient problem and I am still struggling with this.

127.0.0.1 - - [07/Jun/2020 16:16:27] "POST /register/ HTTP/1.1" 500 -
Traceback (most recent call last):
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\_compat.py", line 35, in reraise
    raise value
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request

    rv = self.handle_user_exception(e)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\app.py", line 1718, in handle_user_exception

    reraise(exc_type, exc_value, tb)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\_compat.py", line 35, in reraise
    raise value
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request

    rv = self.dispatch_request()
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask\app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\Keshav Raturi\Desktop\eduthing\app\routes.py", line 47, in register
    u = User.query.filter(or_(User.username==request.form['uname'],User.email==request.form['email'])).first()
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 514, in __get_
_
    return type.query_class(mapper, session=self.sa.session())
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\sqlalchemy\orm\scoping.py", line 78, in __call__
    return self.registry()
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\sqlalchemy\util\_collections.py", line 1012, in __
call__
    return self.registry.setdefault(key, self.createfunc())
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\sqlalchemy\orm\session.py", line 3206, in __call__

    return self.class_(**local_kw)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 143, in __init
__
    bind = options.pop('bind', None) or db.engine
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 877, in engine

    return self.get_engine()
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 896, in get_en
gine
    return connector.get_engine()
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 559, in get_en
gine
    self._engine = rv = sqlalchemy.create_engine(info, **options)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\sqlalchemy\engine\__init__.py", line 455, in creat
e_engine
    return strategy.create(*args, **kwargs)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\sqlalchemy\engine\strategies.py", line 87, in crea
te
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "c:\users\keshav raturi\desktop\eduthing\env\lib\site-packages\sqlalchemy\dialects\mysql\mysqldb.py", line 118, i
n dbapi
    return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'

I downloaded XAMPP also but didn’t get things done and  surely I will update this when everything become fine.


NOTE

Project is under maintenance and is in updating mode.

Choose your Reaction!
Leave a Comment