Git Product home page Git Product logo

awesome-python3-webapp's Introduction

Hello 👋 this is Crypto Michael.

Crypto developer focused on Java, Python, JavaScript, Verilog, etc.

Official website:

awesome-python3-webapp's People

Contributors

michaelliao 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  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

awesome-python3-webapp's Issues

day-04 在测试数据库的时候发生了这个问题,希望大大指点一下,问题出在哪了

报错:
Traceback (most recent call last):
File "E:/pyproject/awesome-python3/123.py", line 13, in
loop.run_until_complete(test(loop))
File "D:\soft\python3.6\lib\asyncio\base_events.py", line 467, in run_until_complete
return future.result()
File "E:/pyproject/awesome-python3/123.py", line 10, in test
await u.save()
File "E:\pyproject\awesome-python3\orm.py", line 190, in save
rows = await execute(self.insert, args)
File "E:\pyproject\awesome-python3\orm.py", line 54, in execute
await cur.execute(sql.replace('?', '%s'), args)
File "D:\soft\python3.6\lib\site-packages\aiomysql\cursors.py", line 239, in execute
yield from self._query(query)
File "D:\soft\python3.6\lib\site-packages\aiomysql\cursors.py", line 460, in _query
yield from conn.query(q)
File "D:\soft\python3.6\lib\site-packages\aiomysql\connection.py", line 398, in query
yield from self._read_query_result(unbuffered=unbuffered)
File "D:\soft\python3.6\lib\site-packages\aiomysql\connection.py", line 582, in _read_query_result
yield from result.read()
File "D:\soft\python3.6\lib\site-packages\aiomysql\connection.py", line 835, in read
first_packet = yield from self.connection._read_packet()
File "D:\soft\python3.6\lib\site-packages\aiomysql\connection.py", line 552, in _read_packet
packet.check_error()
File "D:\soft\python3.6\lib\site-packages\pymysql\connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
File "D:\soft\python3.6\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.NULL.NULL.1504753670.12085.'00150475367012054e14a83e18b4803a3a2d839acba2587000'' at line 1")

关于注册功能

在第10天里边的注册问题
wwww/static里边的文件都是从git下载的,html文件也都没有问题。
在点击完注册按钮后,页面没有反应,
浏览器的地址从
http://127.0.0.1:9000/register
变成了
http://127.0.0.1:9000/register?
数据库里也没有写入新的数据。
也看了原贴下边的一些讨论,没有看到有效的解决方法,特此前来 求教

Lack of TABLE awesome.blogs 缺少table awesome.blogs

The problem is as follow:

pymysql.err.ProgrammingError: (1146, "Table 'awesome.blogs' doesn't exist")

I wonder when can I find the contest of the awesome.blogs?

Hopefully for help and best wishes.

报错:

pymysql.err.ProgrammingError: (1146, "Table 'awesome.blogs' doesn't exist")

awesome.blogs 的内容是什么,在哪可以找到,求教!

day4 最后test的时候出现awesome.user doesnt exist的报错

Traceback (most recent call last):
File "/Users/liulizhong/awesome-python3-webapp/www/test.py", line 15, in
loop.run_until_complete(insert(loop))
File "/anaconda3/lib/python3.6/asyncio/base_events.py", line 473, in run_until_complete
return future.result()
File "/Users/liulizhong/awesome-python3-webapp/www/test.py", line 11, in insert
await u.save()
File "/Users/liulizhong/awesome-python3-webapp/www/orm.py", line 233, in save
rows = await execute(self.insert,args)
File "/Users/liulizhong/awesome-python3-webapp/www/orm.py", line 48, in execute
await cur.execute(sql.replace('?', '%s'), args)
File "/anaconda3/lib/python3.6/site-packages/aiomysql/cursors.py", line 237, in execute
await self._query(query)
File "/anaconda3/lib/python3.6/site-packages/aiomysql/cursors.py", line 455, in _query
await conn.query(q)
File "/anaconda3/lib/python3.6/site-packages/aiomysql/connection.py", line 420, in query
await self._read_query_result(unbuffered=unbuffered)
File "/anaconda3/lib/python3.6/site-packages/aiomysql/connection.py", line 607, in _read_query_result
await result.read()
File "/anaconda3/lib/python3.6/site-packages/aiomysql/connection.py", line 1089, in read
first_packet = await self.connection._read_packet()
File "/anaconda3/lib/python3.6/site-packages/aiomysql/connection.py", line 578, in _read_packet
packet.check_error()
File "/anaconda3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/anaconda3/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1146, "Table 'awesome.user' doesn't exist")

源码是
import orm , asyncio
from models import User, Blog, Comment

async def insert(loop):
await orm.create_pool(loop = loop, user='liusanshui', password='12345', db='awesome')

u = User(name='Test', email='[email protected]', passwd='1234567890', image='about:blank')

await u.save()

loop = asyncio.get_event_loop()
loop.run_until_complete(insert(loop))
loop.run_forever()

for x in insert(loop):
pass

有没有大牛能帮忙看一下

Cannot delete blogs

when i click the delete button, i find that cannot delete blogs. Is there missing some function?

mac 上执行fab build 出现异常,初学者不太懂,在网上找了下也没有看到类似的,但是在我的Windows上是可以的

fab build
[60.205.190.223] Executing task 'build'
[localhost] local: rm -f dist/dist-awesome.tar.gz
[localhost] local: tar --dereference -czvf ../dist/dist-awesome.tar.gz --exclude='test' --exclude='.*' --exclude='*.pyc' --exclude='*.pyo' static templates transwarp favicon.ico *.py
tar: Failed to open '../dist/dist-awesome.tar.gz'

Fatal error: local() encountered an error (return code 1) while executing 'tar --dereference -czvf ../dist/dist-awesome.tar.gz --exclude='test' --exclude='.*' --exclude='*.pyc' --exclude='*.pyo' static templates transwarp favicon.ico *.py'

Aborting.

希望博主能在百忙中抽空帮我解答下,我用博主的github clone 下来运行也是这样

python3 app.py 出错了

Traceback (most recent call last):
File "app.py", line 154, in
loop.run_until_complete(init(loop))
File "/usr/local/python3/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
return future.result()
File "app.py", line 142, in init
yield from orm.create_pool(loop=loop, **configs.db)
File "/home/wwwroot/LNMP/python_web/www/orm.py", line 20, in create_pool
user=kw['awesome_user'],
KeyError: 'awesome_user'

Date7-mvc 测试出现:NameError: name '__pool' is not defined 求帮忙指点一下

找了好久,还是没发现原因,求指点一下
详细代码项目:https://github.com/Mr1yan/awesome-python3-webapp
详细信息:
INFO:root:create database connection pool...
INFO:root:init jinja2...
INFO:root:set jinja2 template path: E:\Python\awesome-python3-webapp\www\templates
INFO:root:found model: User (table: users)
INFO:root: found mapping: id ==> <StringField, varchar(50):None>
INFO:root: found mapping: email ==> <StringField, varchar(50):None>
INFO:root: found mapping: passwd ==> <StringField, varchar(50):None>
INFO:root: found mapping: admin ==> <BooleanField, boolean:None>
INFO:root: found mapping: name ==> <StringField, varchar(50):None>
INFO:root: found mapping: image ==> <StringField, varchar(500):None>
INFO:root: found mapping: created_at ==> <FloatField, real:None>
INFO:root:found model: Blog (table: blogs)
INFO:root: found mapping: id ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_id ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_name ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_image ==> <StringField, varchar(500):None>
INFO:root: found mapping: name ==> <StringField, varchar(50):None>
INFO:root: found mapping: summary ==> <StringField, varchar(200):None>
INFO:root: found mapping: content ==> <TextField, text:None>
INFO:root: found mapping: created_at ==> <FloatField, real:None>
INFO:root:found model: Comment (table: comments)
INFO:root: found mapping: id ==> <StringField, varchar(50):None>
INFO:root: found mapping: blog_id ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_id ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_name ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_image ==> <StringField, varchar(500):None>
INFO:root: found mapping: content ==> <TextField, text:None>
INFO:root: found mapping: created_at ==> <FloatField, real:None>
INFO:root:add route GET / => index(request)
INFO:root:add static /static/ => E:\Python\awesome-python3-webapp\www\static
INFO:root:server started at http://127.0.01:9000...
INFO:root:Request:GET /
INFO:root:Response handler...
INFO:root:call with args:{'request': <Request GET / >}
INFO:root:SQL: select id, email, passwd, admin, name, image, created_at from users
ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
File "E:\Python\Python36-32\lib\site-packages\aiohttp\web_protocol.py", line 421, in start
resp = yield from self._request_handler(request)
File "E:\Python\Python36-32\lib\site-packages\aiohttp\web.py", line 303, in _handle
resp = yield from handler(request)
File "E:/Python/awesome-python3-webapp/www/app.py", line 46, in logger
return (await handler(request))
File "E:/Python/awesome-python3-webapp/www/app.py", line 64, in response
r=await handler(request)
File "E:\Python\Python36-32\lib\site-packages\aiohttp\web_urldispatcher.py", line 113, in handler_wrapper
result = yield from result
File "E:\Python\awesome-python3-webapp\www\coreweb.py", line 138, in call
r=await self._func(**kw)
File "E:\Python\Python36-32\lib\asyncio\coroutines.py", line 223, in coro
res = yield from await_meth()
File "E:\Python\awesome-python3-webapp\www\handlers1.py", line 13, in index
users=await User.findAll()
File "E:\Python\awesome-python3-webapp\www\orm.py", line 188, in findAll
rs = await select(' '.join(sql), args)
File "E:\Python\awesome-python3-webapp\www\orm.py", line 32, in select
async with __pool.get() as conn:
NameError: name '__pool' is not defined
INFO:aiohttp.access:127.0.0.1 - - [10/Jul/2017:16:47:31 +0000] "GET / HTTP/1.1" 500 330 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"

Day3 orm.py Undefined variable 'StandardError'

python 版本 Python 3.7.3
vscode 中显示 orm.py 报错: Undefined variable 'StandardError'
class ModelMetaclass(type):

def __new__(cls, name, bases, attrs):
    if name=='Model':
        return type.__new__(cls, name, bases, attrs)
    tableName = attrs.get('__table__', None) or name
    logging.info('found model: %s (table: %s)' % (name, tableName))
    mappings = dict()
    fields = []
    primaryKey = None
    for k, v in attrs.items():
        if isinstance(v, Field):
            logging.info('  found mapping: %s ==> %s' % (k, v))
            mappings[k] = v
            if v.primary_key:
                # 找到主键:
                if primaryKey:
                    raise StandardError('Duplicate primary key for field: %s' % k)

stackoverflow 中有个回答, "exception StandardError which was removed in Python 3.",是这样的吗?

Errors in [ orm.py ] files in all branchs

in orm.py file, and in line 22.
db=kw['db'] should change to
db = kw['database']
since in config_default.py , you defines
configs = { 'debug': True, 'db': { 'host': '123.206.28.72', 'port': 3306, 'user': 'root', 'password': '12345', 'database': 'awesome' }, 'session': { 'secret': 'AwEsOmE' } }

I runned through the code.

day10: 点击注册后页面出现:网络好像出问题了 (HTTP 500)

我按照廖老师的教程,想注册一个用户名后点击提交有错误,希望帮我解决一下:
点击后页面出现:网络好像出问题了 (HTTP 500)

INFO:root:server started at http://127.0.0.1:9000...
INFO:root:Request: GET /register
INFO:root:Response handler...
INFO:root:call with args: {}
INFO:aiohttp.access:127.0.0.1 - - [14/Dec/2017:07:54:29 +0000] "GET /register HTTP/1.1" 200 6587 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8"
INFO:root:Request: POST /api/users
INFO:root:Response handler...
INFO:root:call with args: {'email': '[email protected]', 'name': 'ka', 'passwd': '4ff03fb6437edad36af5fd180c42ec483983c1fc'}
/Users/k.den/awesome-python3-webapp/www/handlers.py:132: RuntimeWarning: coroutine 'Model.findAll' was never awaited
users = yield from User.findAll('email=?', [email])
ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 417, in start
resp = yield from self._request_handler(request)
File "/anaconda3/lib/python3.6/site-packages/aiohttp/web.py", line 289, in _handle
resp = yield from handler(request)
File "app.py", line 43, in logger
return (await handler(request))
File "app.py", line 61, in response
r = await handler(request)
File "/anaconda3/lib/python3.6/site-packages/aiohttp/web_urldispatcher.py", line 111, in handler_wrapper
result = yield from result
File "/Users/den/awesome-python3-webapp/www/coroweb.py", line 138, in call
r = yield from self._func(**kw)
File "/anaconda3/lib/python3.6/asyncio/coroutines.py", line 213, in coro
res = yield from res
File "/Users/den/awesome-python3-webapp/www/handlers.py", line 132, in api_register_user
users = yield from User.findAll('email=?', [email])
TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator

TypeError: __init__() takes 1 positional argument but 2 were given

Traceback (most recent call last):
  File "E:\Anaconda3\lib\site-packages\aiohttp\web_protocol.py", line 410, in st
art
    resp = yield from self._request_handler(request)
  File "E:\Anaconda3\lib\site-packages\aiohttp\web.py", line 325, in _handle
    resp = yield from handler(request)
  File "E:\Anaconda3\lib\site-packages\aiohttp\web_middlewares.py", line 93, in
impl
    return (yield from handler(request))
  File "app.py", line 61, in logger
    return (yield from handler(request))
  File "app.py", line 100, in auth
    return (yield from handler(request))
  File "app.py", line 120, in response
    r = yield from handler(request)
  File "E:\Anaconda3\lib\site-packages\aiohttp\web_urldispatcher.py", line 142,
in handler_wrapper
    result = yield from result
  File "G:\0pythonstudy\chengxu\webAPP python廖雪峰\PureBlog-master\www\web_fram
e.py", line 200, in __call__
    return web.HTTPBadRequest('Missing argument: %s' % name)
TypeError: __init__() takes 1 positional argument but 2 were given

这是什么情况,求赐教!

Day07 jinja2模版文件TemplateSyntaxError: unexpected '}'

照着test.html敲进去或者直接copy test.html一直报jinja2.exceptions.TemplateSyntaxError: unexpected '}'

我的test.html如下,看着模版文件写的语法没问题呀

<title>Test users - Awesome Python Webapp</title>

All users

{% for u in users %}

{{ u.name }} / {{ u.email }}

{% endfor %}

orm.py 模块excute函数里面affected变量可能存在referenced before assignment.

async def execute(sql, args, autocommit = True):
 
   ....
    async with __pool.get() as conn:
       ...
        try:
            async with conn.cursor(aiomysql.DictCursor) as cur:
                await cur.execute(sql.replace('?','%s'),args)
                affected = cur.rowcount
                 ....
        except BaseException:
              .....
        return affected

在这个代码里面 cur.execute(sql.replace('?','%s'),args) 如果执行错误的话(例如重复插入unique key相同的数据),下面的local variable affected 变量不会被申明且赋值,而在try外面 affected 又被返回,此时会报错,且在调用excute函数的外面并没有捕获异常导致程序崩溃.

day4测试代码出现'yield from' inside async function

clone工程变切换branch到day4运行以下测试代码
`
import orm
from models import User, Blog, Comment

def test():
yield from orm.create_pool(user='www-data', password='www-data', database='awesome')

u = User(name='Test', email='[email protected]', passwd='1234567890', image='about:blank')

yield from u.save()

for x in test():
pass
出现了这个错误在windows上,python3.6.2
$ python test_model.py
Traceback (most recent call last):
File "test_model.py", line 1, in
import orm
File "C:\Users\Administrator\Desktop\github\awesome-python3-webapp\www\orm.py", line 16
__pool = yield from aiomysql.create_pool(
^
SyntaxError: 'yield from' inside async function
`
查了2天资料没找到问题出在哪,不知道是不是python版本的问题

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.