• django显示图片


    dirctory

    vickey_django vickey(projectname) vickey __init__.py __pycache__ settings.py urls.py wsgi.py website(appname) admin.py apps.py __init__.py migrations models.py tests.py views.py manage.py db.sqlite3
    steps
    
    add appname to settings.py and the host
        vickey/vickey/settings.py
            add to APPS_INSTALL[...'website']
      ALLOWED_HOSTS = ['*']      #*填服务器ip,也可以填* change content at views.py and urls.py vickey
    /mywebsite/views.py def index(request): #coding:utf-8 from django.http import HttpResponse return HttpResponse("welcome to vickey's website") vickey/website/urls.py from website import views urlpatterns = [..., url(r'^welcome$',views.index),]
    #如果80端口被占用,可以用netstat -tunlp | grep 80查找到pid用kill -9 pid杀掉 (tunlp 是tcp,udp,number,listen,process)
    #然后在工程目录下启动Django工程:python manage.py runserver ip:80
    vickey/vickey/urls.py
        from mywebsite import views as mywebsite
        urlpatterns = [
            url(r'^iloveyou$', mywebsite.love, name='love'),
            ]
    
    vickey/mywebsite/views.py
        def love(request):
            return render(request, 'love.html')
    
    #mkdir templates under app mywebsite to save html
    #and  static/pic/ to save static such as pic、css、js
    vickey/mywebsite/static/pic/love.jpg
    vickey/mywebsite/templates/love.html
        <img name="love" id="love" src="static/pic/love.jpg">
  • 相关阅读:
    7. 配置undo表空间
    8. Truncate undo表空间
    品味ZooKeeper之Watcher机制_2
    品味ZooKeeper之纵古观今_1
    《Andrew Ng深度学习》笔记5
    《Andrew Ng深度学习》笔记4
    《Andrew Ng深度学习》笔记3
    《Andrew Ng深度学习》笔记2
    《Andrew Ng深度学习》笔记1
    回归算法
  • 原文地址:https://www.cnblogs.com/vickey-wu/p/7400573.html
Copyright © 2020-2023  润新知