简体   繁体   中英

sending html in django http response

I'm new to webdevelopment. i'm trying to send a html string as a response and my server is hosted by ptyhtonanywhere. This is my urls.py

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^plot/',response),]

This is my views function

def response(request):
    html = '<!DOCTYPE html><html><head></head><body>blah/body></html>'
    return HttpResponse(html)

when access the /plot/ url it says 'If this is your PythonAnywhere-hosted site, then you're almost there — you just need to create a web app to handle this domain.' But i'm just trying to send a html response to the browser. Isn't it supposed to display the html content. what am I missing?

first you need to read django document.and add your app in setting.py.second you must include your app urls.py into urls.py in main directory of your project.after all this you should read this :

https://docs.djangoproject.com/en/1.10/topics/http/shortcuts/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM