Skip to content

create a simple HTTP server in Python and share data between the Python code and the HTML code

Notifications You must be signed in to change notification settings

kikunayar/easyhost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

USAGE-EXAMPLE

  • Quick use
import easyhost.EasyHost as eh
host1 = eh.EasyHost(port=1234) # turn on http://localhost:1234/
host1.set(route='/wasdwasdwasd', file='example.png') #also able .html .mp4 etc..
input("Press Enter to exit...")
  • Full use
import easyhost.EasyHost as eh
host1 = eh.EasyHost(port=1234)
host1.set(route='/wasdwasdwasd', file='example.html')
host1.set_shared_dict(dict_path='worldlove/dog', arg=555)
dog_love = host1.get_shared_dict('worldlove/dog')
input("Press Enter to exit...")
<!DOCTYPE html>
<html>
<head>
    <title>Shared Dict Example</title>
</head>
<body>
    <script>
        // Update the value in the shared dictionary
        async function updateValue() {
            await setSharedDict('worldlove/dog', true);
            const value = await getSharedDict('worldlove/dog');
            document.getElementById('result').textContent = `Dog love: ${value}`;
        }
    </script>
</body>
</html>

INSTALLATION

pip install https://github.com/kikunayar/easyhost.git

About

create a simple HTTP server in Python and share data between the Python code and the HTML code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages