Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Love this, it will run a web server! (sort of)

echo 'My test page' > index.html

python3 -m http.server

  Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
curl http://0.0.0.0:8000/index.html

  My test page
--

You can even "install" and RUN Django

python -m pip install Django

  Collecting Django
  Downloading https://files.pythonhosted.org..... [snip]
django-admin startproject mysite

cd ./mysite

python manage.py runserver

  Watching for file changes with StatReloader
  Performing system checks...
  ...[snip]...
  Starting development server at http://127.0.0.1:8000/
  Quit the server with CONTROL-C.
curl http://127.0.0.1:8000/

  <!DOCTYPE html>
  <html>
  <head>
  <title>Welcome to Django</title>
  ...[snip]
create a views.py file with a single view called 'home', have it return a simple http response with with text 'Hello there!'

cat views.py

  from django.http import HttpResponse

  def home(request):
      return HttpResponse("Hello there!")
add the 'home' view from views.py to the url definitions in urls.py for the path '/'

  from django.contrib import admin
  from django.urls import path
  from .views import home

  urlpatterns = [
      path('admin/', admin.site.urls),
      path('/', home),
  ]
curl http://127.0.0.1:8000/

  Hello there!
--

This is mad!



I don't know if someone should try an xml entity combinatorial explosion .. it would be nice scientifically but would it cause problems ?


Try it.


I didn't dare to try higher than 2 levels

https://imgur.com/a/MPXQ79l




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: