zoukankan      html  css  js  c++  java
  • 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">
  • 相关阅读:
    MATLAB 编程风格指南及注意事项
    Redis笔记
    HDU-5706
    【sqli-labs】 less4 GET
    【sqli-labs】 less3 GET
    【sqli-labs】 less2 GET
    【sqli-labs】 less1 GET
    Ubuntu14.04环境下java web运行环境搭建
    Android进度条控件ProgressBar使用
    Android中DatePicker与TimePicker用法讲解(包括DatePickerDialog与TimePickerDialog)
  • 原文地址:https://www.cnblogs.com/vickey-wu/p/7400573.html
Copyright © 2011-2022 走看看