Copas dulu file contoh.py di Pycharm ya Gan (Code Editor khusus PYTHON)
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello, World!')
if __name__ == '__main__':
with Configurator() as config:
# Define a route and the corresponding view
config.add_route('home', '/')
config.add_view(hello_world, route_name='home')
# Create the WSGI application
app = config.make_wsgi_app()
# Start the server
from wsgiref.simple_server import make_server
httpd = make_server('0.0.0.0', 6543, app)
print("Serving on port 6543...")
httpd.serve_forever()
Jangan lupa RUN di Terminal
pip install pyramid
(bisa di awal atau diakhir pengCodingan ya Gan)
Dan utk Eksekusi RUN
python contoh.py
Setelah itu browsing di
http://localhost:6543/
(cukup dgn ketik host di Browser ya Gan dan tidak perlu insert nama file yg dieksekusi)
No comments:
Post a Comment