run-dev-server 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/bin/sh
  2. # outgoing requests
  3. # $ pip install requests-http-signature --user
  4. # $ sudo pacman -S python-cryptography python-requests
  5. # resolving dependencies...
  6. # looking for conflicting packages...
  7. #
  8. # Packages (5) python-asn1crypto-0.24.0-2 python-cffi-1.12.2-1 python-ply-3.11-2
  9. # python-pycparser-2.19-1 python-cryptography-2.6.1-1
  10. #
  11. # $ sudo pacman -S python-termcolor
  12. # Packages (1) python-termcolor-1.1.0-6
  13. # local dev only
  14. # $ sudo pacman -S gunicorn
  15. # dev run - calls application() fn in forgefed_wsgi.py
  16. export FORGEFED_HOSTNAME='c7fcb87a.ngrok.io'
  17. gunicorn --workers 2 --threads 2 --reload forgefed_wsgi:application
  18. ## example data ##
  19. read -r -d '' DB_OBJ <<-'DBOBJ'
  20. {
  21. '_tables':
  22. {
  23. 'activities':
  24. [
  25. {
  26. '@context' : 'https://www.w3.org/ns/activitystreams' ,
  27. 'attributedTo' : 'alice@example.net' ,
  28. 'cc' : [ 'alice@example.net/followers' ] ,
  29. 'content' : '<p>Hello Note</p>' ,
  30. 'id' : '12a8a47295735f7e' ,
  31. 'published' : '2019-03-08T21:09:14Z' ,
  32. 'sensitive' : False ,
  33. 'source' : { 'mediaType' : 'text/plain', 'content': 'Hello Note' } ,
  34. 'tag' : [] ,
  35. 'to' : [ 'bob@example.net' ] ,
  36. 'type' : 'Note' ,
  37. 'url' : 'https://example.net:5000/alice@example.net/note/12a8a47295735f7e' ,
  38. '_id' : ObjectId('5c8300f946d13f16edc1c77a')
  39. }
  40. ] ,
  41. 'actors':
  42. [
  43. {
  44. '@context' : 'https://www.w3.org/ns/activitystreams' ,
  45. 'endpoints' : {} ,
  46. 'followers' : 'alice@example.net/followers' ,
  47. 'following' : 'alice@example.net/following' ,
  48. 'id' : 'alice@example.net' ,
  49. 'inbox' : 'alice@example.net/inbox' ,
  50. 'liked' : 'alice@example.net/liked' ,
  51. 'likes' : 'alice@example.net/likes' ,
  52. 'outbox' : 'alice@example.net/outbox' ,
  53. 'type' : 'Person' ,
  54. 'url' : 'https://example.net:5000/alice@example.net' ,
  55. '_id' : ObjectId('5c8300f946d13f16edc1c779')
  56. }
  57. {
  58. '@context' : 'https://www.w3.org/ns/activitystreams' ,
  59. 'endpoints' : {} ,
  60. 'followers' : 'bob@example.net/followers' ,
  61. 'following' : 'bob@example.net/following' ,
  62. 'id' : 'bob@example.net' ,
  63. 'inbox' : 'bob@example.net/inbox' ,
  64. 'liked' : 'bob@example.net/liked' ,
  65. 'likes' : 'bob@example.net/likes' ,
  66. 'outbox' : 'bob@example.net/outbox' ,
  67. 'type' : 'Person' ,
  68. 'url' : 'https://example.net:5000/bob@example.net' ,
  69. '_id' : ObjectId('5c8300f946d13f16edc1c77a')
  70. }
  71. ]
  72. }
  73. }
  74. DBOBJ
  75. read -r -d '' REQ_ENV <<-'REQENV'
  76. env =>{ 'wsgi.errors': <gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f2f9a283ac8>,
  77. 'wsgi.version': (1,
  78. 0),
  79. 'wsgi.multithread': False,
  80. 'wsgi.multiprocess': False,
  81. 'wsgi.run_once': False,
  82. 'wsgi.file_wrapper': <class 'gunicorn.http.wsgi.FileWrapper'>,
  83. 'SERVER_SOFTWARE': 'gunicorn/19.9.0',
  84. 'wsgi.input': <gunicorn.http.body.Body object at 0x7f2f98aa82e8>,
  85. 'gunicorn.socket': <socket.socket fd=9,
  86. family=AddressFamily.AF_INET,
  87. type=SocketKind.SOCK_STREAM,
  88. proto=0,
  89. laddr=('127.0.0.1',
  90. 8000),
  91. raddr=('127.0.0.1',
  92. 43436)>,
  93. 'REQUEST_METHOD': 'GET',
  94. 'QUERY_STRING': '',
  95. 'RAW_URI': '/inbox',
  96. 'SERVER_PROTOCOL': 'HTTP/1.1',
  97. 'HTTP_HOST': '127.0.0.1:8000',
  98. 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Iceape/2.49.4',
  99. 'HTTP_ACCEPT': 'text/html,
  100. application/xhtml+xml,
  101. application/xml;q=0.9,
  102. */*;q=0.8',
  103. 'HTTP_ACCEPT_LANGUAGE': 'en-US,
  104. en;q=0.5',
  105. 'HTTP_ACCEPT_ENCODING': 'gzip,
  106. deflate',
  107. 'HTTP_DNT': '1',
  108. 'HTTP_CONNECTION': 'keep-alive',
  109. 'HTTP_UPGRADE_INSECURE_REQUESTS': '1',
  110. 'HTTP_CACHE_CONTROL': 'max-age=0',
  111. 'wsgi.url_scheme': 'http',
  112. 'REMOTE_ADDR': '127.0.0.1',
  113. 'REMOTE_PORT': '43436',
  114. 'SERVER_NAME': '127.0.0.1',
  115. 'SERVER_PORT': '8000',
  116. 'PATH_INFO': '/inbox',
  117. 'SCRIPT_NAME': '' }
  118. REQENV
  119. # flaskmanager experiments
  120. # $ sudo pacman -S python-html2text python-bleach
  121. # $ pip install libsass --user
  122. # $ sudo pacman -S python-flask
  123. # Packages (4) python-click-7.0-1 python-itsdangerous-1.1.0-1 python-werkzeug-0.14.1-3
  124. # python-flask-1.0.2-2
  125. # $ sudo pacman -S python-flask-wtf
  126. # Packages (2) python-wtforms-2.2.1-4 python-flask-wtf-0.14.2-2
  127. # log/(master![0<-->0]) 2018-07-28 Update README.md
  128. # $ sudo pacman -S python-sqlalchemy
  129. # pip install codecov mdx_linkify pyld --user
  130. # sudo pacman -S python-pytest python-pytest-cov python-httpretty python-black flake8 mypy python-bleach python-requests python-markdown python-pycryptodome python-html2text python-regex
  131. # Packages (28) python-apipkg-1.5-1 python-atomicwrites-1.3.0-1 python-attrs-18.2.0-1
  132. # python-coverage-4.5.2-1 python-entrypoints-0.3-1 python-iniconfig-1.0.0-2
  133. # python-mccabe-0.6.1-2 python-more-itertools-4.3.0-1 python-mypy_extensions-0.4.1-1
  134. # python-pluggy-0.9.0-1 python-psutil-5.5.0-1 python-py-1.7.0-1
  135. # python-pycodestyle-2.5.0-1 python-pyflakes-2.1.1-1 python-toml-0.10.0-1
  136. # python-typed-ast-1.2.0-1 flake8-1:3.7.7-1 mypy-0.660-1 python-black-18.9b0-3
  137. # python-bleach-3.1.0-1 python-html2text-2018.1.9-2 python-httpretty-0.9.6-1
  138. # python-markdown-3.0.1-2 python-pycryptodome-3.7.3-1 python-pytest-4.3.0-1
  139. # python-pytest-cov-2.6.1-1 python-regex-2019.02.18-1 python-requests-2.21.0-1