Coder Social home page Coder Social logo

afourmy / flask-gentelella Goto Github PK

View Code? Open in Web Editor NEW
573.0 573.0 193.0 29.31 MB

Gentelella template powered by Flask

Home Page: https://colorlib.com/polygon/gentelella/index.html

License: MIT License

Python 1.76% CSS 14.35% JavaScript 10.08% HTML 73.74% Mako 0.04% Dockerfile 0.02% Shell 0.01%
docker dockerfile flask flask-gentelella flask-sqlalchemy gentelella gentelella-template

flask-gentelella's People

Contributors

afourmy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask-gentelella's Issues

js is not working

I got a weird problem!! the page do not change after refreshing when I try to modify the file of custom.js ,it makes me upset, can you offer me some suggestions?

can not add a new column in class User

if I add a new column into User class in app/base/models.py

class User(db.Model, UserMixin):

    __tablename__ = 'User'

    id = Column(Integer, primary_key=True)
    username = Column(String, unique=True)
    email = Column(String, unique=True)
    password = Column(Binary)
    newcolumn = Column(String, unique=True)

I will get error that the database has no such column

sqlalchemy.exc.OperationalError
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: User.newcolumn
[SQL: SELECT "User".id AS "User_id", "User".username AS "User_username", "User".email AS "User_email", "User".password AS "User_password", "User".newcolumn AS "User_newcolumn"
FROM "User"
WHERE "User".id = ?
LIMIT ? OFFSET ?]
[parameters: ('1', 1, 0)]
(Background on this error at: http://sqlalche.me/e/e3q8)

sqlalchemy cannot import name 'Binary'

my env is windows 10
flask run --host=0.0.0.0 ImportError was raised:
...
File "D:\flask-gentelella-master\app\base\models.py", line 3, in
from sqlalchemy import Binary, Column, Integer, String
ImportError: cannot import name 'Binary'

Why do I get a 500 error after login?

I've cloned the repository locally and install everything without any issue. I've created a new user. When I'm trying to login launch an internal server error. The error in the console is this one:

Exception on /login [POST]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/alejandro/MATIS/brain-mixer-project/flask-gentelella/app/base/routes.py", line 48, in login
if user and checkpw(password.encode('utf8'), user.password):
File "/usr/local/lib/python2.7/dist-packages/bcrypt/init.py", line 101, in checkpw
raise TypeError("Unicode-objects must be encoded before checking")
TypeError: Unicode-objects must be encoded before checking`

The weird thing is that when I've tried the docker option it works fine.

Could you help me with this?

Why do I have to GET twice each time I refresh the page?

Why do I have to GET twice each time I refresh the page?

127.0.0.1 - - [26/Jul/2018 15:35:38] "GET /home/index HTTP/1.1" 200 -
127.0.0.1 - - [26/Jul/2018 15:35:38] "GET /home/index HTTP/1.1" 200 -
127.0.0.1 - - [26/Jul/2018 15:35:51] "GET /home/index HTTP/1.1" 200 -
127.0.0.1 - - [26/Jul/2018 15:35:51] "GET /home/index HTTP/1.1" 200 -
127.0.0.1 - - [26/Jul/2018 15:36:13] "GET /home/index2 HTTP/1.1" 200 -
127.0.0.1 - - [26/Jul/2018 15:36:13] "GET /home/index2 HTTP/1.1" 200 -

Error: While importing 'gentelella', an ImportError was raised.

Installed the pip packages in my environment and set the flask app, but can't seem to run flask-gentelella?

(gen-venv) C:\Python\Python310\Projects\flask-gentelella>set FLASK_APP=gentelella.py

(gen-venv) C:\Python\Python310\Projects\flask-gentelella>flask run --host=0.0.0.0
 * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
 * Serving Flask app 'gentelella.py' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.

Error: While importing 'gentelella', an ImportError was raised.

(gen-venv) C:\Python\Python310\Projects\flask-gentelella>

in cursor: raise errors.OperationalError("MySQL Connection not available.")

If I set the db as a file in the disk, the template works fine, but setting up as a db in Pythonanywhere, I often get the error "in cursor: raise errors.OperationalError("MySQL Connection not available.")".

Reloading the page once or twice works, but after a few minutes being idle, when I try to click to something, then it happens again. Over and over.

PS: the older website I had in Pythonanywhere used the same mySql configs and was working fine.

I just can't figure out what's happening. Do you know about this issue?

paid theme on themeforest !

hi,
your work is awesome! there are very few readymade flask admin templates out there. FYI, if you put this on themefores - there will be a lot of us who are willing to pay for it.

thanks!

document the signup form process

I am struggling a bit to follow the process that the signup form uses.

I can see the route.py which pulls in the forms.py and makes an instance of the form
login_form = LoginForm(request.form)
I can see the create user form has the
onclick="signup()"
which it gets from static/build/js/login.js and that this posts the data to /create_user as json and if successful it simlautes a click on the login form.

what i dont get is where is the login submit going? I assume it posts to itself but i dont see how that is happening.

Could you summarise for me pls.

Sorry if these are noob questions im only a beginner.

Oh and is there a reason that the login page includes the js scripts inline in the body instead of in a scripts block?

How to run this project in Pycharm?

Hi
My OS is Windows 10.
I was able to run it successful in cmd by following those instruction. I am wondering how to run it in Pycharm?

Thank you.

can not run this code on the latest version

I'd like to run this code. However, after pip install -r requirements.txt and try to run on my mac laptop. I got some error message like below:
@app.before_first_request AttributeError: 'Flask' object has no attribute 'before_first_request'. Did you mean: '_got_first_request'?

Due to package version. Would you help add the version number in the requirement.txt which could run the code? Thank you.

error in executing

when ever i execute on my windows 10 i get

Error: Detected factory "create_app" in module "app", but could not call it without arguments. Use "FLASK_APP='app:create_app(args)'" to specify arguments.

Install failing with python setup.py egg_info" failed with error code 1 in /private/var/folders/58/_zw7g73x1lv5zt4bjrl3nwsc0000gn/T/pip-install-rd1itnkv/psycopg2/

The pip install -r requirements.txt is failing when installing psycopg2.

Collecting psycopg2
  Using cached https://files.pythonhosted.org/packages/52/be/f898e712f5f08131d651a62754fca82a1deb42e4e9889ad01932f770a2be/psycopg2-2.8.1.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).


    ----------------------------------------
Command "python setup.py egg_info" failed with error code

Trying to get flask to run the app then fails with a first message of:

Error: While importing "gentelella", an ImportError was raised:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 235, in locate_app
    __import__(module_name)
  File "/Users/steve/dev/flask-gentelella/gentelella.py", line 1, in <module>
    from flask_migrate import Migrate
ModuleNotFoundError: No module named 'flask_migrate'

could not translate host name "db" to address: Unknown host

I am trying to run the app in a windows 10 pc.
Afer running the command "flask run" the app will run with host = 120.0.0.1:5000.
When I try to access the address from a browser then following error comes:

  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    Exception on / [GET]
    Traceback (most recent call last):
    File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2262, in _wrap_pool_connect
    return fn()
    File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 354, in connect
    return _ConnectionFairy._checkout(self)
    File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 751, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
    File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 483, in checkout
    rec = pool._do_get()
    File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\impl.py", line 138, in _do_get
    self._dec_overflow()
    File "c:\anaconda3\lib\site-packages\sqlalchemy\util\langhelpers.py", line 68, in exit
    compat.reraise(exc_type, exc_value, exc_tb)
    File "c:\anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 129, in reraise
    raise value
    File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\impl.py", line 135, in _do_get
    return self._create_connection()
    File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 299, in _create_connection
    return _ConnectionRecord(self)
    File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 428, in init
    self.__connect(first_connect_check=True)
    File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 630, in __connect
    connection = pool.invoke_creator(self)
    File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\strategies.py", line 114, in connect
    return dialect.connect(*cargs, **cparams)
    File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\default.py", line 453, in connect
    return self.dbapi.connect(*cargs, **cparams)
    File "c:\anaconda3\lib\site-packages\psycopg2_init
    .py", line 127, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
    psycopg2.OperationalError: could not translate host name "db" to address: Unknown host

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "c:\anaconda3\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "c:\anaconda3\lib\site-packages\flask\app.py", line 1945, in full_dispatch_request
self.try_trigger_before_first_request_functions()
File "c:\anaconda3\lib\site-packages\flask\app.py", line 1993, in try_trigger_before_first_request_functions
func()
File "C:\Users\ruval\flask-gentelella\app_init_.py", line 27, in initialize_database
db.create_all()
File "c:\anaconda3\lib\site-packages\flask_sqlalchemy_init_.py", line 1039, in create_all
self.execute_for_all_tables(app, bind, 'create_all')
File "c:\anaconda3\lib\site-packages\flask_sqlalchemy_init
.py", line 1031, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "c:\anaconda3\lib\site-packages\sqlalchemy\sql\schema.py", line 4287, in create_all
ddl.SchemaGenerator, self, checkfirst=checkfirst, tables=tables
File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2032, in _run_visitor
with self._optional_conn_ctx_manager(connection) as conn:
File "c:\anaconda3\lib\contextlib.py", line 112, in enter
return next(self.gen)
File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2024, in _optional_conn_ctx_manager
with self._contextual_connect() as conn:
File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2226, in _contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2266, in _wrap_pool_connect
e, dialect, self
File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1536, in _handle_dbapi_exception_noconnection
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "c:\anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "c:\anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2262, in _wrap_pool_connect
return fn()
File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 354, in connect
return _ConnectionFairy._checkout(self)
File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 751, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 483, in checkout
rec = pool._do_get()
File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\impl.py", line 138, in _do_get
self._dec_overflow()
File "c:\anaconda3\lib\site-packages\sqlalchemy\util\langhelpers.py", line 68, in exit
compat.reraise(exc_type, exc_value, exc_tb)
File "c:\anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 129, in reraise
raise value
File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\impl.py", line 135, in _do_get
return self._create_connection()
File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 299, in _create_connection
return _ConnectionRecord(self)
File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 428, in init
self.__connect(first_connect_check=True)
File "c:\anaconda3\lib\site-packages\sqlalchemy\pool\base.py", line 630, in __connect
connection = pool.invoke_creator(self)
File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "c:\anaconda3\lib\site-packages\sqlalchemy\engine\default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "c:\anaconda3\lib\site-packages\psycopg2_init
.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "db" to address: Unknown host

(Background on this error at: http://sqlalche.me/e/e3q8)

running tests in docker container?

Can someone give me pointers to getting the tests to run in a docker container?

Here is the Dockerfile I am using:

FROM python:3.6
COPY requirements.txt .
COPY requirements_dev.txt .
COPY ./ /app
RUN pip install -r requirements_dev.txt
EXPOSE 5000
WORKDIR /app/source

And the docker-compose.yml file I am using:

version: "2.1"

services:
    web:
        container_name: web
        build: .
        command: gunicorn --log-file=- --bind 0.0.0.0:5000 --workers 5 app:app
        ports:
            - "5000:5000"
        env_file: secrets.env
        environment:
            - DEBUG=${DEBUG:-0}
        restart: unless-stopped
        links:
            - db
    db:
        container_name: db
        image: postgres:10.4
        env_file: secrets.env
        restart: unless-stopped
        volumes:
            - ./pgdata:/var/lib/postgresql/data

Here is the command I am using to run the tests:

docker-compose run web coverage run --source=../app -m pytest ../tests/

And this is the error I am getting:

Starting db ... done
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/_pytest/config/__init__.py", line 372, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/app/tests')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/_pytest/config/__init__.py", line 403, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/app/tests/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/_pytest/config/__init__.py", line 409, in _importconftest
    mod = conftestpath.pyimport()
  File "/usr/local/lib/python3.6/site-packages/py/_path/local.py", line 686, in pyimport
    raise self.ImportMismatchError(modname, modfile, self)
py._path.local.LocalPath.ImportMismatchError: ('conftest', '/Users/jack/code/flask-gentelella/tests/conftest.py', local('/app/tests/conftest.py'))
ERROR: could not load /app/tests/conftest.py

Since I am running inside a Docker container I am confused as to how it is even detecting /Users/jack/code/flask-gentelella/tests/conftest.py (which is on my host machine).

I found references online saying I need to make sure to delete any __pycache__ folders before building the docker image, but that did not help. I also made sure there was no volume sharing between the container and my host machine.

Any help would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.